Python 2.7 PIP install to use Artifactory as proxy - python

I have configured Jfrog Artifactory as remote repo for PIP module. When I install the pexcept module on Centos 7 OS, its downloading using the Artifactory proxy , but its giving below error message. Also it trying to connect https://pypi.python.org/pypi/pip/json website.
Any tips to fix below error? Also How can I force pip command to use always internal Artifacotry proxy not to connect any external repo directly.
Requirement already satisfied (use --upgrade to upgrade): ptyprocess>=0.5 in /usr/lib/python2.7/site-packages (from pexpect)
Installing collected packages: pexpect
Compiling /tmp/pip-build-bKzDu5/pexpect/pexpect/_async.py ...
File "/tmp/pip-build-bKzDu5/pexpect/pexpect/_async.py", line 20
transport, pw = yield from asyncio.get_event_loop()\
^
SyntaxError: invalid syntax
Successfully installed pexpect-4.7.0
Cleaning up...
Looking up "https://pypi.python.org/pypi/pip/json" in the cache
No cache entry available
Starting new HTTPS connection (1): pypi.python.org
There was an error checking the latest version of pip
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/utils/outdated.py", line 126, in pip_version_check
headers={"Accept": "application/json"},
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 487, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/download.py", line 378, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 467, in send
raise ConnectionError(e, request=request)
ConnectionError: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /pypi/pip/json (Caused by NewConnectionError('<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f5c16190d10>: Failed to establish a new connection: [Errno 97] Address family not supported by protocol',))
remote site setting:

I am presently using artifactory for just this purpose. I did find that some packages did not resolve well. After changing to https://files.pythonhosted.org as the registry URL everything just fell into place.
my other settings are
Repository URL: https://files.pythonhosted.org
Registry Layout simple-layout
Pypi settings
Registry URL: https://pypi.org
Registry Suffix: simple

Related

Cannot use pip to install packages, it reports an error on ssl certificate [duplicate]

This question already has answers here:
'pip install' fails for every package ("Could not find a version that satisfies the requirement") [duplicate]
(2 answers)
pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"
(55 answers)
Closed 4 years ago.
Just now I update the latest python and want to install packages through pip, but there raise a error:
Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/search.py", line 45, in run
pypi_hits = self.search(query, options)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/search.py", line 62, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1243, in __call__
return self.__send(self.__name, args)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1602, in __request
verbose=self.__verbose
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/download.py", line 775, in request
headers=headers, stream=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 522, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
SSLError: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)
I google this error and tried to update Openssl, but it does not work.
My Openssl version is OpenSSL 1.0.2o 27 Mar 2018
My python version is Python 2.7.14
My pip version is pip 9.0.1
My ~/.base_profile is like this:
export PATH=/usr/local/bin:$PATH
PATH=$PATH:/usr/local/mysql/bin
# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH="/usr/local/opt/openssl/bin:$PATH"
someone said it is because some micro changes by shadowsocks, but it did not explain why and how to deal with it.
So what should I do to repair my pip and ssl?
As I answered here https://stackoverflow.com/a/49798838/9586409.
You have to upgrade pip to a version with a TLSv1.2 support. You can do it by running this command:
curl https://bootstrap.pypa.io/get-pip.py | python

Installing twisted on Windows 10 64 bit under python 2.7

Does anyone know how to do this. I have googled and the best that I could come up with was to do:
pip install autobahn[twisted]
when I do that I get this error in the command window
C:\Users\<User Name>\Desktop>pip install autobahn[twisted]
Collecting autobahn[twisted]
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading autobahn-18.3.1-py2.py3-none-any.whl (283kB)
100% |################################| 286kB 1.0MB/s
Collecting txaio>=2.7.0 (from autobahn[twisted])
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
c:\python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: 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/security.html#insecureplatformwarning.
InsecurePlatformWarning
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "c:\python27\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "c:\python27\lib\site-packages\pip\download.py", line 821, in unpack_url
hashes=hashes
File "c:\python27\lib\site-packages\pip\download.py", line 659, in unpack_http_url
hashes)
File "c:\python27\lib\site-packages\pip\download.py", line 853, in _download_http_url
stream=True,
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "c:\python27\lib\site-packages\pip\download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "c:\python27\lib\site-packages\pip\_vendor\requests\adapters.py", line 497, in send
raise SSLError(e, request=request)
SSLError: [Errno 1] _ssl.c:504: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
I have no idea how to fix the error
Go to University of California Irvine's Unofficial Windows Binary for Python Extension Packages and download the Twisted wheel file. This is the easy way. The hard way requires a compiler (comes packaged in Windows Built Tools) to be installed.
PLEASE NOTE!!!! For anyone stumbling onto this thread, only the latest package is available for download (usually) through the University of California Irvine site, so it would be wise to SAVE the binaries for future use. This is very useful if a specific version is required. Otherwise the specific compiler needs to used to compile packages.
References
Microsoft Visual C++ Compiler for Python 3.4
https://wiki.python.org/moin/WindowsCompilers

error while installing graphlab in ubuntu

I am getting the following error while installing graphlab in ubuntu 14.04. I already spent lot of time to solve this problem by googling it. can any one help me to solve this prblem.
Error:
ramy#ramy-Aspire-4739Z:~$ sudo pip install --upgrade https://get.graphlab.com/GraphLab-Create/2.1/mohangtrichy#gmail.com/<KEY>/GraphLab-Create-License.tar.gz
Downloading/unpacking https://get.graphlab.com/GraphLab-Create/2.1/mohangtrichy#gmail.com/<KEY>/GraphLab-Create-License.tar.gz
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1198, in prepare_files
do_download,
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1376, in unpack_url
self.session,
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 546, in unpack_http_url
resp = session.get(target_url, stream=True)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 467, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/sessions.py", line 558, in send
r = adapter.send(request, **kwargs)
File "/usr/share/python-wheels/requests-2.2.1-py2.py3-none-any.whl/requests/adapters.py", line 385, in send
raise SSLError(e)
SSLError: [Errno 1] _ssl.c:510: error:14077438:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert internal error
Storing debug log for failure in /home/ramy/.pip/pip.log
ramy#ramy-Aspire-4739Z:~$
Requests can verify SSL certificates for HTTPS requests, just like a
web browser. To check a host’s SSL certificate, you can use the verify
argument:
And if you want to avoid the SSLError you can find the requests part and change verify to False:
requests.get('https://google.com', verify=False)
Another way reinstall certifi module:
sudo pip uninstall -y certifi
sudo pip install certifi==2015.04.28
Have a look at these questions:
Python Requests throwing up SSLError
SSLError: bad handshake, Python requests

pip fails to make a secure connection to pypi server

Yesterday I tried to install some python packages with pip and it just won't work.
paquete#paquete-ultrabook:~$ pip install isort -v
Downloading/unpacking isort
Could not fetch URL https://pypi.python.org/simple/isort/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0)
Will skip URL https://pypi.python.org/simple/isort/ when looking for download links for isort
Could not fetch URL https://pypi.python.org/simple/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0)
Will skip URL https://pypi.python.org/simple/ when looking for download links for isort
Cannot fetch index base URL https://pypi.python.org/simple/
Could not fetch URL https://pypi.python.org/simple/isort/: connection error: [Errno 0] _ssl.c:344: error:00000000:lib(0):func(0):reason(0)
Will skip URL https://pypi.python.org/simple/isort/ when looking for download links for isort
Could not find any downloads that satisfy the requirement isort
Cleaning up...
Removing temporary dir /tmp/pip_build_paquete...
No distributions at all found for isort
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1177, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 277, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for isort
Storing debug log for failure in /tmp/tmpl86YQE
I've been arround searching for an answer in the internet without success. A lot of answers from 2012 suggest to downgrade, but the bug that was troublesome had been fixed since that.
paquete#paquete-ultrabook:~$ pip -V
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
Some people had issues with their python interpreter, but it seems to connect fine to the server.
paquete#paquete-ultrabook:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import httplib
>>> conn = httplib.HTTPSConnection("pypi.python.org")
>>> conn.request("GET","/simple/")
>>> res = conn.getresponse()
>>> print res.status, res.reason
200 OK
As additional information, I did an elementaryos fresh install a few weeks ago. This happens to ALL packages. I have installed everything through apt, so this seems Any ideas?
Update
Following the suggestion by #andersson I tried to install pip's latest version. Then this poped out
paquete#paquete-ultrabook:~$ sudo python3 Downloads/get-pip.py -v
The directory '/home/paquete/.cache/pip/log' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/paquete/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Starting new HTTPS connection (1): pypi.python.org
There was an error checking the latest version of pip
Traceback (most recent call last):
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 253, in ssl_wrap_socket
context.load_verify_locations(ca_certs)
ssl.SSLError: unknown error (_ssl.c:2734)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 341, in _make_request
self._validate_conn(conn)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 762, in _validate_conn
conn.connect()
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/connection.py", line 238, in connect
ssl_version=resolved_ssl_version)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py", line 255, in ssl_wrap_socket
raise SSLError(e)
pip._vendor.requests.packages.urllib3.exceptions.SSLError: unknown error (_ssl.c:2734)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/tmp8w985p0e/pip.zip/pip/utils/outdated.py", line 126, in pip_version_check
headers={"Accept": "application/json"},
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 476, in get
return self.request('GET', url, **kwargs)
File "/tmp/tmp8w985p0e/pip.zip/pip/download.py", line 367, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 464, in request
resp = self.send(prep, **send_kwargs)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/tmp/tmp8w985p0e/pip.zip/pip/_vendor/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
pip._vendor.requests.exceptions.SSLError: unknown error (_ssl.c:2734)
It seems to be a generic problem.
My problem was slightly different. It looks like the https://pypi.python.org/simple/ certificate was renewed in June 2016, so if the date of your OS is prior to that date, you'll have problems validating the certificate, no matter if the proper CA certs are installed.
I have also some issues with default (1.5.4) pip version. Can you successfully update pip to up-to-date (6.1.1) version or you have already tried and instalation failed with both pip versions?
Promptly solved by:
sudo update-ca-certificates

Pip install from requirements file is failing, but installing one by one works

I am trying to install a bunch of python dependencies using a requirements.txt file with the following command:
pip install -r requirements.txt
The requirements.txt file has the following packages:
pep8
selenium
paramiko
soappy
nose
wmi
mock
python-keystoneclient
python-novaclient
python-cinderclient
python-swiftclient
python-glanceclient
python-heatclient
python-neutronclient
But when running the pip install command I am getting this error:
Downloading/unpacking PrettyTable>=0.7,<0.8 (from python-keystoneclient->-r requ
irements.txt (line 9))
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\basecommand.py", line
122, in main
status = self.run(options, args)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\commands\install.py",
line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl
e=self.bundle)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\req.py", line 1197, i
n prepare_files
do_download,
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\req.py", line 1375, i
n unpack_url
self.session,
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\download.py", line 54
6, in unpack_http_url
resp = session.get(target_url, stream=True)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\_vendor\requests\sess
ions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\download.py", line 23
7, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\_vendor\requests\sess
ions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\_vendor\requests\sess
ions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\VirtualEnvs\test\lib\site-packages\pip\_vendor\requests\adap
ters.py", line 381, in send
raise ProxyError(e)
ProxyError: Cannot connect to proxy. Socket error: [Errno 10054] An existing con
nection was forcibly closed by the remote host.
Storing debug log for failure in C:\Users\cjmarti2\pip\pip.log
But for some reason if I install all packages using pip install <package> they all get installed correctly.
A couple of things to consider;
1) since I am in my company's intranet I am setting a proxy using set https_proxy=https://company-proxy.com:port. 2) Installing the exact same packages using requirements.txt in a Linux machine works fine. Any ideas?
Update:
I was using Python 2.7 for 64 bits. I uninstalled it and installed the 32 bits, and I no longer had this problem. Looks like the python version was the problem, the 64 bits one for some reason cause problems.

Categories