Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy connection error with pipenv install but pip install works fine #4314

Closed
gioxc88 opened this issue Jun 3, 2020 · 14 comments
Closed

Proxy connection error with pipenv install but pip install works fine #4314

gioxc88 opened this issue Jun 3, 2020 · 14 comments
Labels
Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. triage

Comments

@gioxc88
Copy link

gioxc88 commented Jun 3, 2020

Version

pipenv version 2020.6.2
pip 20.1.1
python 3.7.7

Issue description

Running simply pipenv install numpy fails with the following message again and again

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProxyError('Cannot connecnnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x000002581488BCC8>: Failed to establish a new connection: [rinfo failed'))': /simple/numpy/

I am behind a corporate proxy but running pip install works fine.
I have a pip.ini file where I specify the trusted hosts and the extra index urls and it seems that pipenv is reading this because, before the error I can read:

 pipenv install numpy
Installing numpy…
Error:  An error occurred while installing numpy!
Error text: Looking in indexes: https://pypi.org/simple, https://bloomberg.bintray.com/pip/simple

Any way to make it work?
Many thanks

@gioxc88
Copy link
Author

gioxc88 commented Jun 5, 2020

any update on this?

@frostming
Copy link
Contributor

Do you have any proxy settings in pip.conf?

@gioxc88
Copy link
Author

gioxc88 commented Jun 5, 2020

I do, I also set the environment variables.
The strange thing is that pip works fine

@jouve
Copy link

jouve commented Jun 9, 2020

the proxy is set with $https_proxy.
the proxy is doing mitm.

cat ~/.config/pip/pip.conf
[global]
trusted-host = pypi.org
               files.pythonhosted.org

it seems that pipenv is doing http requests on it's own now using requests:

Traceback (most recent call last):
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/resolver.py", line 807, in <module>
    main()
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/resolver.py", line 803, in main
    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/resolver.py", line 785, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/resolver.py", line 753, in resolve_packages
    requirements_dir=requirements_dir,
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/resolver.py", line 736, in resolve
    req_dir=requirements_dir
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/utils.py", line 1386, in resolve_deps
    req_dir=req_dir,
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/utils.py", line 1096, in actually_resolve_deps
    results = resolver.clean_results()
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/utils.py", line 1002, in clean_results
    collected_hashes = self.collect_hashes(ireq)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/utils.py", line 885, in collect_hashes
    r = session.get(pkg_url, timeout=10)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/home/xxxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/six/json (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:727)'),))

@jouve
Copy link

jouve commented Jun 9, 2020

my workaround is to add the CA to the cacert.pem from certifi in site-packages (/home/xxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/certifi/cacert.pem in my case)

@gioxc88
Copy link
Author

gioxc88 commented Jun 9, 2020

Thank you all for the answer.
And I thank for the effort the guys who wrote the package.
However I am giving up on pipenv, too much pain. I literally spend days trying to make it work in different occasions but always had problems. Locking takes hours and nothing ever goes straight.

I am switching do the built in venv, which, by the way, is the preferred method for python 3.3+

Gio

@gkedge
Copy link

gkedge commented Aug 17, 2020

my workaround is to add the CA to the cacert.pem from certifi in site-packages (/home/xxxx/.local/share/virtualenvs/pipenv-2020.6.2-BlFqa2vD/lib/python3.8/site-packages/pipenv/vendor/certifi/cacert.pem in my case)

I was unable to get any relief after adding certs this way for my internal mirror.

I would really like to be able to use pipenv without Internet access.

@image357
Copy link

image357 commented Oct 8, 2020

I can confirm this problem

@image357
Copy link

image357 commented Oct 8, 2020

I fixed it by using

pip install requests[security]

inside the environment where pipenv is installed (most probably global) and exporting the environment variables "HTTP_PROXY" and "HTTPS_PROXY" (usually only one is relevant).

$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"

See for example: https://requests.readthedocs.io/en/master/user/advanced/#proxies

@everton-o
Copy link

I was facing the same problem, I fixed by adding a pip.ini file.

https://stackoverflow.com/questions/59817886/using-pipenv-behind-a-proxy

@sdutton-personal
Copy link

Also seeing this.
Pip only will respect the environment variables as well as the pip.ini file, but non pipenv, it just does its own thing.

@MrDataPsycho
Copy link

I have set up the environment variables in my .zhsrc/.bashrc and it works. Did not needed to add anything extra and it works.

export HTTP_PROXY=http://<url>:<port>
export HTTPS_PROXY=http://<url>:<port>   

Or you might need to add username and password also to make it work.

export HTTP_PROXY=http://<user>:<password>@<url>:<port>
export HTTPS_PROXY=http://<user>:<password>@<url>:<port>   

I am using the first approach and it works for me. You can read more details on the advance usecase document from the request library as @image357 mentioned.

@matteius
Copy link
Member

Please try pipenv=2022.8.17

@matteius matteius added the Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. label Aug 17, 2022
@matteius
Copy link
Member

matteius commented Sep 3, 2022

This effort which should be in the next release should allow users to pass the proxy= flag and other additional arguments to pip install: #5283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting Update ⏳ This issue requires more information before assistance can be provided. triage
Projects
None yet
Development

No branches or pull requests

9 participants