Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SSL Error when using pip
#1
Sad 
I am new in IT and I am a Linux Mint user.

I am facing an issue when I try to install libraries using pip.

If, in Terminal, I type:

pip3 install pytest

... then I get this below as output:

Quote:WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pytest/
Could not fetch URL https://pypi.org/simple/pytest/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pytest/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pytest (from versions: none)
ERROR: No matching distribution found for pytest
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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
WARNING: There was an error checking the latest version of pip.


I use:

Quote:python 3.11.0 ( /home/rofarah/.pyenv/shims/python )
Linux Mint 21.1 (Vera)
pip 22.3 (/home/rofarah/.pyenv/shims/pip)

If, in terminal, I type:

ls -ls /usr/bin/python*

... here is the result:
Quote:0 lrwxrwxrwx 1 root root 10 Aug 18 07:39 /usr/bin/python3 -> python3.10
5784 -rwxr-xr-x 1 root root 5921160 Nov 14 13:10 /usr/bin/python3.10
0 lrwxrwxrwx 1 root root 34 Nov 14 13:10 /usr/bin/python3.10-config -> x86_64-linux-gnu-python3.10-config
0 lrwxrwxrwx 1 root root 17 Aug 18 07:39 /usr/bin/python3-config -> python3.10-config
4 -rwxr-xr-x 1 root root 977 Dec 24 2021 /usr/bin/python-dotenv

ls /usr/local/lib/ | grep python

Quote: libpython3.10.a
libpython3.7m.a
python3.10
python3.7

whereis python3

Quote: /usr/bin/python3
/usr/lib/python3
/etc/python3
/usr/share/python3
/home/rofarah/.pyenv/shims/python3
/usr/share/man/man1/python3.1.gz

Can anyone please help me?

Regards,

Rodrigo.


Previously I have followed this 90 min tutorial, step-by-step: https://youtu.be/B8ImmR2GfYQ ... but no results, I am facing the same issue.
Reply
#2
pip has to be run from the command (terminal) prompt
from prompt type python -V
and pip -V
they should be using same interpreter.
Please reposrt results.

for scraping, I suggest you start here, you can do both tutorials (written by Snippsat) quickly:

Web-Scraping part-1
Web-Scraping part-2
Reply
#3
(Jan-31-2023, 06:58 PM)Larz60+ Wrote: pip has to be run from the command (terminal) prompt
from prompt type python -V
and pip -V
they should be using same interpreter.
Please reposrt results.

Hi @Larz60+ ! Thank you so much for your reply!

This is what I get when I check versions:

➜ python -V
Python 3.11.0

~ …
➜ pip -V
pip 22.3 from /home/rofarah/.pyenv/versions/3.11.0/lib/python3.11/site-packages/pip (python 3.11)

Other important information:

ls /usr/local/lib/ | grep python

libpython3.10.a
libpython3.7m.a
python3.10
python3.7


whereis pyhton3

python3:
/usr/bin/python3
/usr/lib/python3
/etc/python3
/usr/share/python3
/home/rofarah/.pyenv/shims/python3
/usr/share/man/man1/python3.1.gz

The link below is a good approach that I found. Please, check out the only reply to this thread:
https://stackoverflow.com/questions/7457...ssl-module
I followed those steps, but no success. Sad

Kind regards,

Rodrigo.
Reply
#4
you are trying to run python from shims directory in .pyenv .
This is not the way to use shims.
Virtual environment must be started,
so where for project is located, run from command line (Linux) . ./venv/bin/activate
python (and the proper version for the virtual environment) will now be available from this environment.
try to see if you can get thsi far.
once you have your virtual environment up and running,
try from command line:
python
>>>
>>> print('hello')
hello

>>> quit()
Reply
#5
(Jan-31-2023, 11:57 PM)Larz60+ Wrote: so where for project is located, run from command line (Linux) . ./venv/bin/activate
python (and the proper version for the virtual environment) will now be available from this environment.
try to see if you can get thsi far.
once you have your virtual environment up and running,
try from command line:
python
>>>
>>> print('hello')
hello

>>> quit()

Hi Larz,

Here it goes:

TI/Code/Django_Course_OM …
➜ . venv/bin/activate

TI/Code/Django_Course_OM via Django_Course_OM …
➜ python
Python 3.11.0 (main, Nov 23 2022, 16:44:35) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello')
Hello
>>> quit()

But after that, if I type: pip install pytest , the same error message appears.

Quote:you are trying to run python from shims directory in .pyenv .
This is not the way to use shims.
Virtual environment must be started,

As I am new in programming, honestly I don't know how did I come to use python this wrong way. Do you have any suggestion how to fix this mistake?

By the way, I am trying this solution below:

Quote:I simply modified part of the file Modules/Setup.dist

from

# 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
to

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/etc/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto
Notice that /etc/ssl is the actual location where I have ssl installed.

After the file modification I than installed with

sudo ./configure --enable-optimizations
sudo make altinstall
And now (after eventually upgrading pip and setuptools) pip works fine.

The problem is there is no setup.dist file inside Python 3.11.0 Modules. So there is this guy who wrote:

Quote:For Python 3.11.1 on Ubuntu 22.04.1, you do not need to modify any distribution files, just add --with-openssl-rpath=/usr/lib/x86_64-linux-gnu to the ./configure command line.

The ssl & crypto libs are in that directory, and this ensures they're located at runtime

Note this assumes you're running on an x86_64 distro, I expect there's a similar directory on ARM.

I am trying to do this (last quote), but terminal does't know "./configure" command. I think maybe I should execute ./configure in a different directory (maybe /usr/lib ?).

What do you think?

Thank you so much for your attention,

Rodrigo.
Reply
#6
the product is located in .pyenv/shims/python3.11, but not to be run from here. should never be run from here

please see: pyenv Simple Python Version Management

You aparently already have pyenv installed, so don't attempt to reinstall, but still need vitrual environment.
Do not go any further until you read and understand Snippsat's tutorial (above)
Reply
#7
Hi, @Larz60+ ! How are you doing?

(Feb-01-2023, 10:53 AM)Larz60+ Wrote: please see: pyenv Simple Python Version Management

You aparently already have pyenv installed, so don't attempt to reinstall, but still need vitrual environment.

Yes, everything seems to be ok between Python and pyenv:

➜ pyenv version
3.11.0 (set by /home/rofarah/.pyenv/version)

~ …
➜ python -V
Python 3.11.0

(Feb-01-2023, 10:53 AM)Larz60+ Wrote: Do not go any further until you read and understand Snippsat's tutorial (above)

I am embarrassed, but as I am new in IT, and I have to admit that I don't understand what "web scraping" (Snippsat's tutorial) has to do with this "SSL - pip - Python" issue I am facing. Could you please give me a light on this?

Furthermore, even though I activate venv on VS Code terminal (already programming with my project folder opened), pip is not working, pip is not installing libraries because of this SSL error message.
Reply
#8
Maybe you aren't allowed to dowload packages from pypi.
Larz60+ likes this post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020