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

Pipenv read TIMEOUT error #3110

Closed
oleksis opened this issue Oct 27, 2018 · 6 comments
Closed

Pipenv read TIMEOUT error #3110

oleksis opened this issue Oct 27, 2018 · 6 comments

Comments

@oleksis
Copy link

oleksis commented Oct 27, 2018

python3 --version
Python 3.6.5

pip --version
pip 18.1 from /usr/lib/python3.6/site-packages/pip (python 3.6)

pipenv --version
pipenv, version 2018.10.9

pip._vendor.urllib3.exceptions.ReadTimeoutError

(MarketDroid-gJO6am4_) oleksis@linux-fkos:~/MarketDroid> pipenv install django
Installing django…
Collecting django
Downloading https://files.pythonhosted.org/packages/32/ab/22530cc1b2114e6067eece94a333d6c749fa1c56a009f0721e51c181ea53/Django-2.1.2-py3-none-any.whl (7.3MB)

Error: An error occurred while installing django!
Exception:
Traceback (most recent call last):
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4_/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 331, in error_catcher
yield
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 413, in read
data = self.fp.read(amt)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/lib64/python3.6/http/client.py", line 449, in read
n = self.readinto(b)
File "/usr/lib64/python3.6/http/client.py", line 493, in readinto
n = self.fp.readinto(b)
File "/usr/lib64/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/usr/lib64/python3.6/ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib64/python3.6/ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "/usr/lib64/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4_/lib/python3.6/site-packages/pip/internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/commands/install.py", line 318, in run
resolver.resolve(requirement_set)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_internal/resolve.py", line 102, in resolve
self.resolve_one(requirement_set, req)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_internal/resolve.py", line 256, in _resolve_one
abstract_dist = self.get_abstract_dist_for(req_to_install)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_internal/resolve.py", line 209, in get_abstract_dist_for
self.require_hashes
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/operations/prepare.py", line 283, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/download.py", line 836, in unpack_url
progress_bar=progress_bar
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/download.py", line 673, in unpack_http_url
progress_bar)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_internal/download.py", line 897, in _download_http_url
download_url(resp, link, content_file, hashes, progress_bar)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_internal/download.py", line 617, in download_url
hashes.check_against_chunks(downloaded_chunks)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/utils/hashes.py", line 48, in check_against_chunks
for chunk in chunks:
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/download.py", line 585, in written_chunks
for chunk in chunks:
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/utils/ui.py", line 159, in iter
for x in it:
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/internal/download.py", line 574, in resp_read
decode_content=False):
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/vendor/urllib3/response.py", line 465, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 430, in read
raise IncompleteRead(self.fp_bytes_read, self.length_remaining)
File "/usr/lib64/python3.6/contextlib.py", line 99, in exit
self.gen.throw(type, value, traceback)
File "/home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4
/lib/python3.6/site-packages/pip/_vendor/urllib3/response.py", line 336, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

Using pip with --timeout General Options:

(MarketDroid-gJO6am4_) oleksis@linux-fkos:~/MarketDroid> pipenv run pip install --upgrade --timeout 3600 django
Loading .env environment variables…
Collecting django
Downloading https://files.pythonhosted.org/packages/32/ab/22530cc1b2114e6067eece94a333d6c749fa1c56a009f0721e51c181ea53/Django-2.1.2-py3-none-any.whl (7.3MB)
100% |████████████████████████████████| 7.3MB 2.6MB/s
Requirement already satisfied, skipping upgrade: pytz in /home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4_/lib/python3.6/site-packages (from django) (2018.5)
Installing collected packages: django
Found existing installation: Django 2.1
Uninstalling Django-2.1:
Successfully uninstalled Django-2.1
Successfully installed django-2.1.2

pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError

(MarketDroid-gJO6am4_) oleksis@linux-fkos:~/MarketDroid> pipenv update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
ireq = self.resolve_reqs(download_dir, ireq, wheel_cache)
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 296, in resolve_reqs
results = resolver._resolve_one(reqset, ireq)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/resolve.py", line 263, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/resolve.py", line 213, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 279, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 837, in unpack_url
progress_bar=progress_bar
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 674, in unpack_http_url
progress_bar)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 898, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 618, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/utils/hashes.py", line 48, in check_against_chunks
for chunk in chunks:
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 586, in written_chunks
for chunk in chunks:
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 575, in resp_read
decode_content=False):
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 465, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 430, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib64/python3.6/contextlib.py", line 99, in exit
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 336, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

@oleksis
Copy link
Author

oleksis commented Oct 27, 2018

I set in the .env file the Environment variable:
PIPENV_TIMEOUT=3600

but I think that if I have a very slow internet connection this error occurs.
Thanks!

@techalchemy
Copy link
Member

techalchemy commented Oct 27, 2018

Pipenv doesn’t load .env files for running its own commands, it only loads them for running pipenv shell and pipenv run. Configuration variables for pipenv itself need to be set in your environment.

@techalchemy
Copy link
Member

Closing for now, feel free to let us know if that doesn’t help!

@oleksis
Copy link
Author

oleksis commented Oct 27, 2018

Closing for now, feel free to let us know if that doesn’t help!

I execute the commands from pipenv shell and Pipenv load the file .env . The error happens when you create a connection pool (HTTP/HTTPS) in pipenv.patched.notpip._vendor.urllib3.connectionpool.

How Pipenv set --timeout for HTTPConnectionPool/HTTPSConnectionPool with the environment variable PIPENV_TIMEOUT or PIPENV_INSTALL_TIMEOUT

from socket
socket._GLOBAL_DEFAULT_TIMEOUT = object()

from pipenv.patched.notpip._vendor.urllib3.util.timeout import Timeout
Timeout.DEFAULT_TIMEOUT = _GLOBAL_DEFAULT_TIMEOUT

Thanks!

@oleksis
Copy link
Author

oleksis commented Oct 28, 2018

Hi @techalchemy...
I think that when you try to install a request (example when pipenv lock is executed) it is delegated to the command pip freeze trying to solve the requirement and when making the connection using socket use the TIMEOUT by default which is 30

Pipenv can establish socket connection by adding the --timeout argument in the command or setting it as an environment variable?

Thanks for your help!

@oleksis
Copy link
Author

oleksis commented Oct 29, 2018

Hello @techalchemy
Here I use pipenv shell within the virtual environment I run pipenv update with the option --support and I still have the error Read Timeout Error. As you can see in the output he says he is using the pip -i subcommand. How can you pass the option --timeout the subcommands pipenv, pip, piptools?

MarketDroid> pipenv shell
Loading .env environment variables…
Launching subshell in virtual environment…
. /home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4_/bin/activate
MarketDroid> . /home/oleksis/.local/share/virtualenvs/MarketDroid-gJO6am4_/bin/activate
(MarketDroid-gJO6am4_) oleksis@linux-fkos:~/MarketDroid> pipenv -v --support update
Running $ pipenv lock then $ pipenv sync.
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
using sources: [{'url': 'https://pypi.org/simple', 'verify_ssl': True, 'name': 'pypi'}]
Using pip: -i https://pypi.org/simple

                      ROUND 1                           

Current constraints:
django

Finding the best candidates:
found candidate django==2.1.2 (constraint was )

Finding secondary dependencies:
django==2.1.2 not in cache, need to check index

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 331, in _error_catcher
yield
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 413, in read
data = self._fp.read(amt)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/lib64/python3.6/http/client.py", line 449, in read
n = self.readinto(b)
File "/usr/lib64/python3.6/http/client.py", line 493, in readinto
n = self.fp.readinto(b)
File "/usr/lib64/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/usr/lib64/python3.6/ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib64/python3.6/ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "/usr/lib64/python3.6/ssl.py", line 631, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 101, in
main()
File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 90, in main
system=system,
File "/usr/lib/python3.6/site-packages/pipenv/resolver.py", line 73, in resolve
allow_global=system,
File "/usr/lib/python3.6/site-packages/pipenv/utils.py", line 421, in resolve_deps
req_dir=req_dir,
File "/usr/lib/python3.6/site-packages/pipenv/utils.py", line 302, in actually_resolve_deps
results = resolver.resolve(max_rounds=environments.PIPENV_MAX_ROUNDS)
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 206, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 301, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 235, in get_dependencies
legacy_results = self.get_legacy_dependencies(ireq)
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 416, in get_legacy_dependencies
results, ireq = self.resolve_reqs(download_dir, ireq, wheel_cache)
File "/usr/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 296, in resolve_reqs
results = resolver._resolve_one(reqset, ireq)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/resolve.py", line 263, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/resolve.py", line 213, in _get_abstract_dist_for
self.require_hashes
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/operations/prepare.py", line 279, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 837, in unpack_url
progress_bar=progress_bar
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 674, in unpack_http_url
progress_bar)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 898, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 618, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/utils/hashes.py", line 48, in check_against_chunks
for chunk in chunks:
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 586, in written_chunks
for chunk in chunks:
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_internal/download.py", line 575, in resp_read
decode_content=False):
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 465, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 430, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib64/python3.6/contextlib.py", line 99, in exit
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.6/site-packages/pipenv/patched/notpip/_vendor/urllib3/response.py", line 336, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pipenv.patched.notpip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants