Package upload to pypi.org broken - python

I have been trying to workaround the latest changes to pypi for hours, and I can't find a way to do it. My usual method of running python setup.py register; python setup.py bdist_wheel sdist upload currently fails with an SSL error:
(py27_test) [mpenning#mudslide ciscoconfparse]$ python setup.py register; python setup.py bdist_wheel sdist upload
...
Submitting /home/mpenning/ciscoconfparse/dist/ciscoconfparse-1.3.2-py2.py3-none-any.whl to https://upload.pypi.org/legacy/
error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)>
FWIW twine also fails with SSL errors as well. I tried downloading the SSL PEM certificate for upload.pypi.org, but somehow twine upload --cert ~/.certs/uploadpypiio.pem dist/* also fails with an SSL error:
(py27_test) [mpenning#mudslide ciscoconfparse]$ twine upload --cert ~/.certs/uploadpypiio.pem dist/*
Uploading distributions to https://upload.pypi.org/legacy/
Uploading ciscoconfparse-1.3.2-py2.py3-none-any.whl
SSLError: HTTPSConnectionPool(host='upload.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))
(py27_test) [mpenning#mudslide ciscoconfparse]$
This problem has happened to me before, but I was able to workaround the problem by manually uploading my source distro and wheel to pypi.org; however, even that method fails too (it worked as recently as Jan 29, 2018). When I try a manual package upload, they seem to have disabled it.
Now it seems like I'm completely stuck with no options to fix this breakage.
Question
Is there some way to manually upload packages to pypi that I've missed somehow? Alternately, if there is some twine magic I've missed, I'm open to hearing it. I'm running Python 2.7.9 on Debian 8.1 in a virtualenv.
I've got:
pip version 9.0.1
setuptools version 38.5.1
twine version 1.9.1

Usually ssl error cause by time error. So synchroinze the time will fix it in most case.

Related

PIP / OpenSSL error: "WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available." [duplicate]

This question already has answers here:
"pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available"
(9 answers)
SSL module in Python is not available (on OSX)
(9 answers)
pip gives error "pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available." in mac
(4 answers)
Closed last month.
TL;DR: On MACOS 12.5.1, M1. I am a n00b graduate datascience student. I downloaded anaconda and homebrew miniforge, tried to download Tensorflow. After downloading Tensorflow I started to receive the following errors when using pip or conda install. pip works via jupyter notebooks but not via terminal.
Below is the text of my error readouts.
(venv) (base) duk3y2#DUK3Y6-2 Flask_for_venv % pip install Flask
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/flask/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/flask/ (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 flask (from versions: none)
ERROR: No matching distribution found for Flask
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: There was an error checking the latest version of pip.
(venv) (base) duk3y2#DUK3Y6-2 Flask_for_venv % conda install Flask
Collecting package metadata (current_repodata.json): failed
CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to
download and install packages.
Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/osx-arm64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
/Users/duk3y2/miniforge3/bin:
/Users/duk3y2/miniforge3/condabin:
/opt/homebrew/bin:
/opt/homebrew/sbin:
/Library/Frameworks/Python.framework/Versions/3.10/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/opt/X11/bin
I am sure I did something wrong. I cannot load any packages using pip or pip3. It gives the SSL error from above. There is also a weird line after opening the terminal that I think may potentially be related to the issue: (eval):1: unknown sort specifier
I'm lost, and have to resort to colab or jupyter to complete anything.

Pip install from archive

I am trying to install Dtale in jupyter notebook. Due to the firewall restrictions, I cannot install it online. I tried to download the archive file dtale-2.2.0.tar.gz and ran this command inside the jupyter notes.
pip install <path>/dtale-2.2.0.tar.gz
This fails as it could not find pypandoc. Then I downloaded the pypandoc-1.7.5.tar.gz and ran
pip install <path>/pypandoc-1.7.5.tar.gz.
But this time I get the error:
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/d2/04/08841501db81bceb7a86a98dea7c12b0185fcc69bfdf1aea266f727d1d7e/poetry_core-1.0.8-py2.py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)')))
I know the host is unreachable due to the firewall, that is the reason why I downloaded the package. Can someone guide me through how to install the packages from the .gz archive file?
Thanks
this error tells you that there is a pkg in dependencies that can NOT be downloaded.
its name is poetry-core, so you should download and install it manually.
here is a url for it: https://files.pythonhosted.org/packages/d2/04/08841501db81bceb7a86a98dea7c12b0185fcc69bfdf1aea266f727d1d7e/poetry_core-1.0.8-py2.py3-none-any.whl
in case you can't download it too due to your firewall, you can use VPN.
in case you can't do that either, then you can download it from this url:
https://www.mediafire.com/file/kpnfupmf5px84um/poetry_core-1.0.8-py2.py3-none-any.whl/file
I have downloaded and re-uploaded it

conda error ssl certificate : HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443

no matter what I do I get this error
C:\Users\MyPc>conda update --all
Solving environment: failed
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/win-64/repodata.json.bz2>
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.
SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/win-64/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available."))'))
I have searched all the internet , re-installed anaconda and did whatever is there on suggestion but this issue is still there.
Windows 10
C:\Users\MyPc>anaconda --version
anaconda Command line client (version 1.7.2)
C:\Users\MyPc>conda --version
conda 4.5.12
In my case I got this kind of error message when I try to run this command
conda install tensorflow
here is the Error message
CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to download and install packages.
Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
This is the solution for that
step 01
go to your installation path of anaconda3
step 02
now go to the this file path
anaconda3\Library\bin
step 03
now select this DLL file and copy that
libcrypto-1_1-x64.dll
libssl-1_1-x64.dll
step 04
after that go to this file path and paste that to inside of that folder
anaconda3\DLLs
I had this same issue, and the thing that fixed it for me was to install an earlier 32-bit version of Conda. For some reason the newer 64-bit version seemed prone to this error. You can find an earlier version of Conda here:
https://repo.continuum.io/archive/
You should search for an Anaconda3 version that only has x86, not x86_64.
I had the same problem, the simple solution is:
open anaconda navigator from start menu, then run CMD.exe Prompt, and install from there, that's it.

How to install PIP for IDLE running Python 2.7.5 on Windows 10?

I just downloaded the python 2.7.5 desktop application with Python (command line) and IDLE. I can run a simple python script directly in IDLE but I cannot access python from the windows command prompt. I tried downloading get-pip.py but I couldn't find the location of setup.py on my computer and when I try to run get-pip.py from another location using IDLE it shows this error:
"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(SSLError(1, '_ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version'),)) - skipping [31m Could not find a version that satisfies the requirement pip (from versions: )[0m [31mNo matching distribution found for pip[0m"
How can I install PIP?
Thanks in advance.
Use miniconda2 or minoconda3. Why? Miniconda has a windows installer that if installed correctly, updates the path for you. Miniconda also loads precompiled binaries so you do not need a C++ compiler, which is an annoying problem to run into on windows. Plus miniconda makes virtual enviornment setup a breeze with the command line. Also it comes with PIP if you need to fall back to it.
https://conda.io/miniconda.html

python SSL certificate validation fails on some distribution commands

I'm trying to upload a Python file to PyPi via twine upload <file> but I get an SSL error:
C:\pypubsub>twine upload dist\PyPubSub-4.0.0rc1-py3-none-any.whl
Uploading distributions to https://upload.pypi.org/legacy/
Uploading PyPubSub-4.0.0rc1-py3-none-any.whl
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
Other Python scripts that use SSL have the same problem, for example
with python setup.py bdist_wheel upload <my_package>
with pip install <any_package>; but there I can add --trusted-host pypi.python.org to any pip install command and the installation and downloading of dependencies will succeed
This happens on my corporate laptop whether at home or work, but it doesn't happen on my personal laptop.
To get around this, I basically tried SO answer to similar problem (ie export the certificate that twine is trying to validate -- presumably that of pypi.python.org -- and then tell twine to use it):
from chrome, I went to https://pypi.pythong.org, clicked the lock next to the URL, then Details, View Certificate, Details, Copy to File. This generated a .CER file.
I used SSL Converter to convert the .CER file from DER format to PEM format. This created a .CRT file.
I ran twine as twine upload <my_package> --cert <path to CRT file>; this time the SSL error was SSLError: [SSL] PEM lib (_ssl.c:2846).
I then tried opting out of server certificate validation by patching c:\Python35\lib\ssl.py as described in Opting Out: I replaced the line _create_default_https_context = create_default_context by _create_default_https_context = _create_unverified_context. Re-running the twine command failed again with original CERTIFICATE_VERIFY_FAILED error.
I'm not all that familiar with certificates so I'm at a loss now what else to try.
You can pass a --cert flag to tell twine which certificate to use.
twine upload dist\PyPubSub-4.0.0rc1-py3-none-any.whl --cert <path-to-.pem-file>
To covert a .cer to a .pem file, do the following.
openssl x509 -inform der -in certificate.cer -out certificate.pem
The --cert flag is essential for one who uses custom ssl certs. If you're using a corporate network, the above fix should sort you out. Ask your admin for the ssl certs :)

Categories