Pipenv 无法锁定 Pipfile,无论是在安装模块时还是使用 pipenv 锁
我正在尝试设置 pipelinev 以在我的工作项目中使用。我使用公司代理并设置了 pip.ini 配置文件,这与 pip 一起用于安装和 virtualenv。
不确定这是否是适用于 pip 安装的代理的问题。我还读到可能有一个我需要更改的环境变量。
我尝试安装请求,pipenv 能够创建环境并安装依赖项,但无法锁定 Pipfile。如果我使用--skip-lock就可以安装。但是如果我去安装/更新任何东西,或者用 pipenv lock (包括 --clear)锁定文件,它就会失败。回溯如下,我读得对吗?它是从 SSL 问题开始的?
Traceback (most recent call last):
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\connectionpool.py", line 714, in urlopen
httplib_response = self._make_request(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\connectionpool.py", line 403, in _make_request
self._validate_conn(conn)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\connectionpool.py", line 1053, in _validate_conn
conn.connect()
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\connection.py", line 419, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\util\ssl_.py", line 493, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock, server_hostname=server_hostname)
File "C:\Program Files\Python39\lib\ssl.py", line 501, in wrap_socket
return self.sslsocket_class._create(
File "C:\Program Files\Python39\lib\ssl.py", line 1041, in _create
self.do_handshake()
File "C:\Program Files\Python39\lib\ssl.py", line 1310, in do_handshake
self._sslobj.do_handshake()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\requests\adapters.py", line 486, in send
resp = conn.urlopen(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\connectionpool.py", line 798, in urlopen
retries = retries.increment(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
pipenv.patched.pip._vendor.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/charset-normalizer/json (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\resolver.py", line 675, in <module>
main()
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\resolver.py", line 661, in main
_main(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\resolver.py", line 645, in _main
resolve_packages(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\resolver.py", line 612, in resolve_packages
results, resolver = resolve(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\resolver.py", line 592, in resolve
return resolve_deps(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 918, in resolve_deps
results, hashes, internal_resolver = actually_resolve_deps(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 692, in actually_resolve_deps
hashes = resolver.resolve_hashes
File "C:\Program Files\Python39\lib\functools.py", line 993, in __get__
val = self.func(instance)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 595, in resolve_hashes
self.hashes[ireq] = self.collect_hashes(ireq)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 566, in collect_hashes
hashes = self.project.get_hashes_from_pypi(ireq, source)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\project.py", line 274, in get_hashes_from_pypi
r = session.get(pkg_url, timeout=self.s.PIPENV_REQUESTS_TIMEOUT)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\requests\sessions.py", line 602, in get
return self.request("GET", url, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_internal\network\session.py", line 519, in request
return super().request(method, url, *args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\requests\sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\requests\sessions.py", line 703, in send
r = adapter.send(request, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\cachecontrol\adapter.py", line 76, in send
resp = super().send(request, stream, timeout, verify, cert, proxies)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\patched\pip\_vendor\requests\adapters.py", line 519, in send
raise ConnectionError(e, request=request)
pipenv.patched.pip._vendor.requests.exceptions.ConnectionError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/charset-normalizer/json (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)))
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\Scripts\pipenv.exe\__main__.py", line 7, in <module>
# when invoked as python -m pip <command>
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\cli\options.py", line 58, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\vendor\click\decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\cli\command.py", line 340, in lock
do_lock(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\routines\lock.py", line 65, in do_lock
venv_resolve_deps(
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 859, in venv_resolve_deps
c = resolve(cmd, st, project=project)
File "C:\Users\J1RXF03\AppData\Roaming\Python\Python39\site-packages\pipenv\utils\resolver.py", line 728, in resolve
raise RuntimeError("Failed to lock Pipfile.lock!")
RuntimeError: Failed to lock Pipfile.lock!
有关设置代理值的评论有效。我没有在配置文件前面使用“http://”。然而,这对 SSL 请求造成了不同的问题。我收到一条错误消息,指出我的请求正在尝试使用 https 而不是 http。有人建议我在终端中设置环境变量 HTTP_PROXY 和 HTTPS_PROXY 。最初这并没有解决问题,直到我阅读了错误的措辞。结果我必须将上述两个变量设置为相同的值。
$ENV:HTTP_PROXY='http://代理:端口" $ENV:HTTPS_PROXY='http://proxy:port" <-- 不是 'https://'
请求现在正确地通过代理并完成,然后锁定文件。谢谢大家!