poetry: "Search for package" during poetry init does not work behind a corporate proxy
- I am on the latest Poetry version.
- I have searched the issues of this repo and believe that this is not a duplicate.
- [x ] If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option).
- OS version and name: Ubuntu 18.04.1 LTS
- Poetry version: 0.12.3
- Link of a Gist with the contents of your pyproject.toml file: n/a poetry init fails without generating pyproject.toml file
Issue
When running poetry init in an environment behind a corporate proxy, and attempting to interactively resolve dependencies, it times out during the first run of “Search for package” with the following trace
Would you like to define your dependencies (require) interactively? (yes/no) [yes]
Search for package: requests
[error]
[Errno 110] Connection timed out
Exception trace:
/home/smulcahy/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in run() at line 94
status_code = self.do_run(input_, output_)
/home/smulcahy/.poetry/lib/poetry/console/application.py in do_run() at line 88
return super(Application, self).do_run(i, o)
/home/smulcahy/.poetry/lib/poetry/_vendor/py2.7/cleo/application.py in do_run() at line 197
status_code = command.run(input_, output_)
/home/smulcahy/.poetry/lib/poetry/console/commands/command.py in run() at line 77
return super(BaseCommand, self).run(i, o)
/home/smulcahy/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/base_command.py in run() at line 146
status_code = self.execute(input_, output_)
/home/smulcahy/.poetry/lib/poetry/_vendor/py2.7/cleo/commands/command.py in execute() at line 107
return self.handle()
/home/smulcahy/.poetry/lib/poetry/console/commands/init.py in handle() at line 116
self._determine_requirements(self.option("dependency"))
/home/smulcahy/.poetry/lib/poetry/console/commands/init.py in _determine_requirements() at line 162
matches = self._get_pool().search(package)
/home/smulcahy/.poetry/lib/poetry/repositories/pool.py in search() at line 98
results += repository.search(query, mode=mode)
/home/smulcahy/.poetry/lib/poetry/repositories/pypi_repository.py in search() at line 203
hits = client.search(search, "or")
/usr/lib/python2.7/xmlrpclib.py in __call__() at line 1243
return self.__send(self.__name, args)
/usr/lib/python2.7/xmlrpclib.py in __request() at line 1602
verbose=self.__verbose
/usr/lib/python2.7/xmlrpclib.py in request() at line 1283
return self.single_request(host, handler, request_body, verbose)
/usr/lib/python2.7/xmlrpclib.py in single_request() at line 1311
self.send_content(h, request_body)
/usr/lib/python2.7/xmlrpclib.py in send_content() at line 1459
connection.endheaders(request_body)
/usr/lib/python2.7/httplib.py in endheaders() at line 1038
self._send_output(message_body)
/usr/lib/python2.7/httplib.py in _send_output() at line 882
self.send(msg)
/usr/lib/python2.7/httplib.py in send() at line 844
self.connect()
/usr/lib/python2.7/httplib.py in connect() at line 1255
HTTPConnection.connect(self)
/usr/lib/python2.7/httplib.py in connect() at line 821
self.timeout, self.source_address)
/usr/lib/python2.7/socket.py in create_connection() at line 575
raise err
The problem seems to arise in xmlrpclib which doesn’t include built-in support for http or https proxies. https://docs.python.org/2/library/xmlrpclib.html#example-of-client-usage includes an example of how to instruct xmlrpclib to use a proxy. I’m not sure if the same approach will work for xmlrpc.client.
I’m not sure if poetry wants to default to the proxies defined in the users environment variables if they’re set (typically some of http_proxy, https_proxy, no_proxy, HTTP_PROXY, HTTPS_PROXY, NO_PROXY) or to explicitly require a user to pass a proxy arg to poetry. Either one works although using the environment variables if set is what other tools do by default.
Thanks
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 21 (5 by maintainers)
This was actually a Poetry problem, but due to user error. I couldn’t find the docs which detailed the
poetry self add
syntax, and also didn’t know I was looking for a problem there. My original understanding was that Poetry used the packages in the current venv you are in, so I had pysocks installed there and globally just to make sure, but it still wouldn’t work and none of the previous issues I found detailed how to do it.When I came across the docs for adding packages to the Poetry venv I managed to get it working, but thanks for following up 🙂
Current versions of Poetry respect the
PROXY_
/proxy_
environmental variables inpoetry search
.I’m getting the same ImportError and I’m not using any proxy.
Edit: traceback (poetry init -vvv)
Edit2: this seems to be fixed in 750e31de98b84e294ac6c5798ad8c4656be9dd2e cc @mulcahys
I just tried this in Windows, and I was able to get the proxy to work using:
$ set HTTPS_PROXY=<proxyHost>:<proxyPort>
I think the equivalent in Ubuntu is:$ export HTTPS_PROXY=<proxyHost>:<proxyPort>
If it works, this could be added to your ~/.bashrc as a setting.
If we verify that this works in Ubuntu, this would be a great addition to submit a PR to the documentation.