How to fix Python PIP update failing - python

I am trying to install and use python on Windows 11 for purposes of Meraki API calls. I have installed Python version 3.11 and am now trying to run
pip install --upgrade requests
pip install --upgrade meraki
but these command return the following error
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))': /simple/requests/
ERROR: Could not find a version that satisfies the requirement requests (from versions: none)
ERROR: No matching distribution found for requests
WARNING: There was an error checking the latest version of pip.
I don't think the firewall is blocking it but I am not sure what I need to look for in the firewall - does anyone know the addresses that need to be unblocked?
Or is there another reason for this error?
Thanks!
I tried adding a firewall rule but didn't know what I needed to add.

Try to use another pip index-url
For example:
pip install --upgrade requests -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

Related

Problem when installing Python from source, SSL package missing even though openssl installed

The Problem
Trying to install Python-3.11.1 from source on Zorin OS (Ubuntu16 based) I get the following errors when I try to pip install any package into a newly created venv:
python3.11 -m venv venv
source venv/bin/active
pip install numpy
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, 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/numpy/
WARNING: Retrying (Retry(total=3, 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/numpy/
WARNING: Retrying (Retry(total=2, 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/numpy/
WARNING: Retrying (Retry(total=1, 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/numpy/
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/numpy/
Could not fetch URL https://pypi.org/simple/numpy/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/numpy/ (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 numpy (from versions: none)
ERROR: No matching distribution found for numpy
Obviously, the SSL package seems to be missing, however I made sure to have both openssl and libssl-dev installed before installing python. More specifically, I made sure to have all packages installed lined out here.
The Exact Steps I Took To Install
Make sure all packages that are required are installed (the once above)
cd .../python-installs
Download Python from python.org
tar -xvzf Python-3.11.1.tgz
cd Python-3.11.1 and then
./configure \
--prefix=/opt/python/3.11.1 \
--enable-shared \
--enable-optimizations \
--enable-ipv6 \
--with-openssl=/usr/lib/ssl \
--with-openssl-rpath=auto \
LDFLAGS=-Wl,-rpath=/opt/python/3.11.1/lib,--disable-new-dtags
make <- Note that I get a lot off error messages from gcc here, very similar to this, however it seems its successful at the end
make altinstall
Parts of this installation process are from [1], [2]
Running python3.11 seems to work fine, however I cannot pip install anything into a venv created by Python3.11.1.
Other Possible Error Sources
Before trying to reinstall Python3.11.1, I always made sure to delete all files in the following places that were associated with Python3.11.1:
/usr/local/bin/...
/usr/local/lib/...
/usr/local/man/man1/...
/usr/local/share/man/man1/...
/usr/local/lib/pkgconfig/...
/opt/python/...
I also tried adding Python-3.11.1 to PATH by adding
PATH=/opt/python/3.11.1/bin:$PATH
to /etc/profile.d/python.sh, but it didn't seem to do much in my case.
When configuring the python folder I am using --with-openssl=/usr/lib/ssl, though perhaps I need to use something else? I tried --with-openssl=/usr/bin/openssl but that doesn't work because openssl is a file and not a folder and it gives me an error message and doesn't even configure anything.
Conclusion
From my research I found that most times this error relates to the openssl library not being installed (given that python versions >= 3.10 will need it to be installed), and that installing it and reinstalling python seemed to fix the issue. However in my case it doesn't, and I don't know why that is.
The most likely cause is that something is wrong with my openssl configuration, but I wouldn't know what.
Any help would be greatly appreciated.
After some more research, I realized that I didn't have libbz2-dev installed, which is obviously the first thing one should check if they get the errors above but oh well. For anyone who still finds himself struggling, here are my complete steps I took:
Make sure the following libraries are installed
apt show libbz2-dev
apt show openssl
apt show libssl-dev
# Other libraries that might also be needed
apt show liblzma-dev
cd .../python-installs
Download the target Python version from python.org as Gzipped tar ball
tar -xvzf Python-3.11.1.tgz
sudo mkdir opt/python
sudo mkdir opt/python/3.11.1
cd Python-3.11.1 and then
./configure --prefix=/opt/python/3.11.1 \
--enable-optimizations
make <- Note that I still get a lot of error messages from gcc, also get a always_inline not in line error message
sudo make altinstall
Add PATH=/opt/python/3.11.1/bin:$PATH to the file /etc/profile.d/python.sh
reboot
Then to test if the error is gone one can for example test:
python3.11 -m venv venv
source venv/bin/active
pip install pandas
python3.11
import pandas
exit()
If there are no errors then everything worked out. Obviously the version needs to be changed to the actual target version of yours.
Note
If you your newly installed python version does not appear in terminal, it might be because the file /etc/profile.d/python.sh already existed with the Path to the python version (for example, if you had to install it multiple times). In that case, delete the file (or at least the PATH to the target version) and then recreate it. After rebooting it should appear in terminal.

How to install PIP on python2.7 with python3 already installed, in Windows

I have already installed both Python 3.9.7 and Python 2.7 in my Windows. I need to install some libraries like scipy to run an old project, which is written in Python2.
It's a kinda big project so I prefer not to edit the syntax and make it compatible with Python3.
I have to install pip on my python2 for installing the required libraries. I tried to use the instructions mentioned here.
But I get this error:
c:\users\amerali\appdata\local\temp\tmponnk1_\pip.zip\pip\_vendor\urllib3\util\ssl_.py:164:
InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail.
You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pip/
Which occurs 5-6times, then it gives the following error :
ERROR: Could not find a version that satisfies the requirement pip<21.0 (from versions: none)
ERROR: No matching distribution found for pip<21.0
I tried it with another internet connections as well, but didn't fix it.
Is there any solutions or an alternative way to install pip?

cannot install pandasql in anaconda and having proxy issue

I know this is an old topic but I keep having trouble with installing pandasql in anaconda, I hope someone could help...
what I have tried:
open anaconda prompt, type pip install pandasql, then I got the below error:
"WARNING: Retrying (Retry(total=4, connect = None, read=None, redirect=None, status=None)) after connection broken by 'ConnectTimeoutError... 'Connection to pypi.org timed out. (connect timeout=15)')': /simple/pandasql/"
ERROR: Could not find a version that satisfies the requirement Pandasql (from versions: none)
ERROR: No matching distribution found for Pandasql
I saw some postings saying that it may be proxy issue and I just want to check if my IP is blacklisted by https://pypi.org, then I go curl https://pypi.org
I got the below error:
curl: (28) Failed to connect to pypi.org port 443 after 84242 ms: Timed out
could anyone advise that what else I can do? to install pandasql in anaconda?
Thanks.
Try conda install (package name) instead of pip, since you’re using anaconda already
This page gives you the specific command
https://anaconda.org/anaconda/pandasql

Error while trying to install 'pymongo' libary

I tried to run my code on Linux ad get this error:
ModuleNotFoundError: No module named 'pymongo'
then I install with these commands :
$ pip install pymongo
$ pip install pymongo==2.1.1
$ pip install --upgrade pymongo
and still get an error :
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pymongo/
I've tried to search this error - specific on 'pynomgo' and couldn't find anything.
I'd be happy if anyone can help me here.
thank you in advance.
Please do check your internet connection.
Because the error says read timed out which meant there is a problem in internet connectivity.
If you still can't resolve the problem Please tell which OS you are using.
Because in linux based OS pymongo will be pre-installed.

pip Install throwing No matching distribution found for

I am on my work PC (corporate proxy) and i am unable to install anything using pip install.
I have tried the following:
pip install QuantLib-Python
pip install --proxy 'webproxy.abc.123.nsroot.net:8080' QuantLib-Python
pip install --proxy "user:pass#webproxy.abc.123.nsroot.net:8080" QuantLib-
Python
no matter the library i always receive this message. I am on Python 3.7.3
Collecting QuantLib-Python
Note: you may need to restart the kernel to use updated packages.
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x0000000002BEAFD0>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed')': /simple/quantlib-python/
Retrying
No matching distribution found for QuantLib-Python
On my Home PC i ran the command pip install QuantLib-Python with the version of python and it worked perfectly.
please help!

Categories