'bz2 is module not available' when installing Pandas with pip in python virtual environment

后端 未结 3 1432
北海茫月
北海茫月 2021-01-13 12:51

I am going through this post Numpy, Scipy, and Pandas - Oh My!, installing some python packages, but got stuck at the line for installing Pandas:

pip install         


        
3条回答
  •  醉话见心
    2021-01-13 13:40

    I spent a lot of time on the internet and got a partial answer everywhere. Here is what you need to do to make it work. Follow every step.

    1. sudo apt-get install libbz2-dev Thanks to Freek Wiekmeijer for this.

    Now you also need to build python with bz2. Previously installed python won't work. For the do following:-

    1. Download stable python version from https://www.python.org/downloads/source/ then extract that Gzipped source tarball file. You can use wget https://python-tar-file-link.tgz to download and tar -xvzf python-tar-file.tgz to exact it in current directory

    2. Go inside exacted folder then run following command on at a time

      • ./configure
      • make
      • make install
    3. This will build a python file with bz2 that you previously installed
    4. Since this python doesn't have pip installed, idea was to create a virtual environment with above-built python then install pandas using previously installed pip
    5. You will see python file in the same directory. Just create a virtual environment.
      • ./python -m env myenv (create myenv in the same directory or outside it's your choice)
      • source myenv/bin/activate (activate virtual environment)
      • pip install pandas (install pandas in the current environment)
    6. That's it. Now with this environment, you should be able to use pandas without error.

提交回复
热议问题