9

I'm using Kali Linux 2020.1, I installed Python3.7, then after trying to install modules using pip3 command I keep getting this error message.

  WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
    ERROR: Could not find a version that satisfies the requirement flask (from versions: none)
    ERROR: No matching distribution found for flask

    Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
1
  • Check the openssl version, probably you need update this. Feb 24 at 13:25
3

I think you may have inadvertently installed without something it needs. The error looks similar to one generated by the python requests library.

I would check this is properly installed and it's dependencies are met. I notice that python-openssl is only a suggested package and not a required one. You might want to see if installing this one helps.

Package: python3-requests
Depends: python3-certifi, python3-chardet (<< 3.1.0), python3-idna, python3-urllib3 (<< 1.26), python3:any, ca-certificates, python3-chardet (>= 3.0.2), python3-urllib3 (>= 1.21.1)
Suggests: python3-cryptography, python3-idna (>= 2.5), python3-openssl, python3-socks, python-requests-doc
1

To do we must compile it and install each dependency

  • Download if need https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.x
  • Unpack file
    tar zxvf Python-3.7.0.tar.gz --directory /tmp
    cd /tmp
    
  • Edit file Setup.dist to enabled SSL
    cd Python-3.7.0/Modules/
    vi Setup.dist
    
  • un-comment following line and update openssl home
    SSL=/usr/local/ssl  <--- substitute with your openssl home directory
    _ssl _ssl.c \
            -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
            -L$(SSL)/lib -lssl -lcrypto
    
  • save and compile python for distribution
    cd ../
    ./configure --enable-optimizations CFLAGS="-O3" --prefix=/opt/primeur/python3.7
    make
    make install
    
  • Try it

    cd /opt/primeur/python3.7/bin
    [root@myserver bin]# python3
    
    Python 3.7.0 (default, May 5 2020, 22:31:07)
    
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
    
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    
  • update pip with command

    [root@myserver bin]#./pip3 install --upgrade pip
    
  • install any dependency using pip3 install like

    [root@myserver bin]#./pip3 install termcolor
    
    Collecting termcolor
    Using cached https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
    Installing collected packages: termcolor
    Running setup.py install for termcolor ... done
    Successfully installed termcolor-1.1.0
    
3
  • 2
    It's unusual to install any python module this way. Could you explain why it needs to be built from source rather than installing via one of the mainstream channels? eg: install using apt May 12 '20 at 13:33
  • 1
    because I install on RedHat without YUM May 12 '20 at 16:43
  • 1
    This question is about installing on Kali Linux which does have apt. May 12 '20 at 19:48
0

This solution worked very well for me:

SSL issues with Python 3.7 Install From Source

Thanks Josh.

I make a summary of the procedure:


Steps

I decided to just install openSSL again by pulling down the newest version of the source code.

sudo apt-get install -y wget
mkdir /tmp/openssl
cd /tmp/openssl
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
tar xvf openssl-1.0.2q.tar.gz
cd /tmp/openssl/openssl-1.0.2q
./config
make
sudo make install

The key here (and the reason i’m writing this post) is to show how to tell Python where this new installation of openSSL is. By default your manual install of openSSL will be in /usr/local/ssl. You can confirm this by checking the modify time of the ssl directory with ls -la /usr/local/ssl.

By default, Python isn’t going to look here. We need to fix that. To begin, run the first part of the Python install script (as seen below).

# Install requirements
sudo apt-get install -y build-essential
sudo apt-get install -y checkinstall
sudo apt-get install -y libreadline-gplv2-dev
sudo apt-get install -y libncursesw5-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y libsqlite3-dev
sudo apt-get install -y tk-dev
sudo apt-get install -y libgdbm-dev
sudo apt-get install -y libc6-dev
sudo apt-get install -y libbz2-dev
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y openssl
sudo apt-get install -y libffi-dev
sudo apt-get install -y python3-dev
sudo apt-get install -y python3-setuptools
sudo apt-get install -y wget
# Prepare to build
mkdir /tmp/Python37
cd /tmp/Python37
# Pull down Python 3.7, build, and install
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz

Now STOP, cd to /tmp/Python37/Python-3.7.0 and open up the file Modules/Setup.dist

You should see the following lines COMMENTED.

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
 _ssl _ssl.c \
    -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    -L$(SSL)/lib -lssl -lcrypto

What you need to do is UNCOMMENT these lines so that they are seen during our Python compile. Now you can finish up by running that last few lines of our python script.

cd /tmp/Python37/Python-3.7.0
./configure --enable-optimizations
sudo make altinstall

At this point I now had a working python and pip (mapped to python3.7 and pip3.7 in my path).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.