bndr / bndr/pipreqs

pipreqs online doesn't work behind proxy

Open
#323 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
7.5k
Forks
424
PR merge metrics
No merged PRs in 30d

Description

Without "--use-local", I can't use pipreqs:

Error Traceback

```
>pipreqs
Traceback (most recent call last):
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 700, in urlopen
self._prepare_proxy(conn)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 996, in _prepare_proxy
conn.connect()
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\connection.py", line 414, in connect
self.sock = ssl_wrap_socket(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\util\ssl_.py", line 449, in ssl_wrap_socket
ssl_sock = _ssl_wrap_socket_impl(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\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 (x86)\python 3.9.6\lib\ssl.py", line 500, in wrap_socket
return self.sslsocket_class._create(
File "c:\program files (x86)\python 3.9.6\lib\ssl.py", line 1040, in _create
self.do_handshake()
File "c:\program files (x86)\python 3.9.6\lib\ssl.py", line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py", line 489, in send
resp = conn.urlopen(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\connectionpool.py", line 787, in urlopen
retries = retries.increment(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\urllib3\util\retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/pyodbc/json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files (x86)\python 3.9.6\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\program files (x86)\python 3.9.6\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\Scripts\pipreqs.exe\__main__.py", line 7, in
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\pipreqs\pipreqs.py", line 488, in main
init(args)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\pipreqs\pipreqs.py", line 439, in init
imports = local + get_imports_info(difference,
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\pipreqs\pipreqs.py", line 179, in get_imports_info
response = requests.get(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\api.py", line 73, in get
return request("get", url, params=params, **kwargs)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 723, in send
history = [resp for resp in gen]
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 723, in
history = [resp for resp in gen]
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 266, in resolve_redirects
resp = self.send(
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
File "C:\Users\RUSANAN\AppData\Roaming\Python\Python39\site-packages\requests\adapters.py", line 563, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /pypi/pyodbc/json (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))
```

I also have a pip.ini file configured with a index-url and trusted-host from my company:
pip.ini:
```
[global]
index-url = ...
trusted-host = ...
```

Contributor guide

Open the contributing guide

Research direction

Start at pipreqs.py in get_imports_info, identified by the traceback around line 179, and trace how the online PyPI request is configured. Reproduce the command with the reported pip.ini proxy settings; done means pipreqs can perform the online lookup without the certificate or proxy failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.