UserWarning: Could not import the lzma module. Your installed Python is incomplete

前端 未结 5 1588
-上瘾入骨i
-上瘾入骨i 2020-12-13 06:02

After Installing Google Cloud Bigquery Module, if I import the module into python code. I see this warning message. Happening to me in python 3.7.3 Virtualenv.

Tried

相关标签:
5条回答
  • 2020-12-13 06:18

    On macOS, if you manage your python with pyenv and package with homebrew, you need to install "xz" first:

    brew install xz
    

    After installing xz, you can install python 3.8 by (I'm using 3.8.2 as an example:

    pyenv install 3.8.2
    

    Above will fix the problem.

    0 讨论(0)
  • 2020-12-13 06:28

    If you are using centos and compile python from source, you can install from following commands

    For centos: sudo yum install -y xz-devel

    Recompile python from source code

    cd Python-3.8*/
    ./configure --enable-optimizations
    sudo make altinstall
    
    0 讨论(0)
  • 2020-12-13 06:30

    On MacOS and pyenv (https://realpython.com/intro-to-pyenv/), I was able to have this warning go away by having xz installed with homebrew. Using version python 3.6.9 as an example

    brew install xz && pyenv install 3.6.9

    To use installed python, one needs to add this into .bash_profile

    eval "$(pyenv init -)"

    and start using it by running

    pyenv global 3.6.9

    0 讨论(0)
  • 2020-12-13 06:34

    If you compile Python from source, you must have the lzma-dev package installed, or it will not be built into python.

    For ubuntu: sudo apt-get install liblzma-dev

    For centos: yum install -y xz-devel

    Then configure && make && make install

    0 讨论(0)
  • 2020-12-13 06:38

    I used other good answers from here and didn't solve the problem (Ubuntu 18.04, Python3.8), still get this warning. Actually there is one more package is needed to be installed to solve the problem:

    sudo apt-get install lzma
    

    So the whole pipeline (run in the python source code folder):

    sudo apt-get install liblzma-dev
    sudo apt-get install lzma
    ./configure --enable-optimizations
    sudo make
    sudo make altinstall
    
    0 讨论(0)
提交回复
热议问题