“ssl module in Python is not available” when installing package with pip3

后端 未结 28 1431
别跟我提以往
别跟我提以往 2020-11-22 08:51

I\'ve install Python 3.4 and Python 3.6 on my local machine successfully, but am unable to install packages with pip3.

When I execute pip3 install

相关标签:
28条回答
  • 2020-11-22 09:15

    You can do either of these two:

    1. While installing Anaconda, select the option to add Anaconda to the path.

    or

    1. Find these (complete) paths from your installation folder of Anaconda and add them to the environment variable :

    \Anaconda

    \Anaconda\Library\mingw-w64\bin

    \Anaconda\Library\usr\bin

    \Anaconda\Library\bin

    \Anaconda\Scripts

    \anaconda\Library

    \anaconda\condabin

    Add the above paths to the "Path" system variable and it should show the error no more :)

    0 讨论(0)
  • 2020-11-22 09:17

    I tried A LOT of ways to solve this problem and none solved. I'm currently on Windows 10.

    The only thing that worked was:

    • Uninstall Anaconda
    • Uninstall Python (i was using version 3.7.3)
    • Install Python again (remember to check the option to automatically add to PATH)

    Then I've downloaded all the libs I needed using PIP... and worked!

    Don't know why, or if the problem was somehow related to Anaconda.

    0 讨论(0)
  • 2020-11-22 09:17

    The python documentation is actually very clear, and following the instructions did the job whereas other answers I found here were not fixing this issue.

    1. first, install python 3.x.x from source using, for example with version 3.6.2 https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz

    2. make sure you have openssl installed by running brew install openssl

    3. unzip it and move to the python directory: tar xvzf Python-3.6.2.tar.xz && cd Python-3.6.2

    4. then if the python version is < 3.7, run

    CPPFLAGS="-I$(brew --prefix openssl)/include" \ LDFLAGS="-L$(brew --prefix openssl)/lib" \ ./configure --with-pydebug 5. finallly, run make -s -j2 (-s is the silent flag, -j2 tells your machine to use 2 jobs)

    0 讨论(0)
  • 2020-11-22 09:19

    Agree with the answer by mastaBlasta. Worked for me. I encountered the same problem as the topic description.

    Environment: MacOS Sierra. And I use Homebrew.

    My solution:

    1. Reinstall openssl by brew uninstall openssl; brew install openssl
    2. According to the hints given by Homebrew, do the following:

      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
      export LDFLAGS="-L/usr/local/opt/openssl/lib"
      export CPPFLAGS="-I/usr/local/opt/openssl/include"
      
    0 讨论(0)
  • 2020-11-22 09:19

    If you are on OSX and have compiled python from source:

    Install openssl using brew brew install openssl

    Make sure to follow the instructions brew gives you about setting your CPPFLAGS and LDFLAGS. In my case I am using the openssl@1.1 brew formula and I need these 3 settings for the python build process to correctly link to my SSL library:

    export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
    export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
    

    Assuming the library is installed at that location.

    0 讨论(0)
  • 2020-11-22 09:21

    I encountered the same problem on windows 10. My very specific issue is due to my installation of Anaconda. I installed Anaconda and under the path Path/to/Anaconda3/, there comes the python.exe. Thus, I didn't install python at all because Anaconda includes python. When using pip to install packages, I found the same error report, pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available..

    The solution was the following:

    1) you can download python again on the official website;

    2) Navigate to the directory where "Python 3.7 (64-bit).lnk"is located

    3) import ssl and exit()

    4) type in cmd, "Python 3.7 (64-bit).lnk" -m pip install tensorflow for instance.

    Here, you're all set.

    0 讨论(0)
提交回复
热议问题