question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Search for package" during poetry init does not work behind a corporate proxy

See original GitHub issue
  • 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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:6
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
neersightedcommented, Oct 11, 2022

Current versions of Poetry respect the PROXY_/proxy_ environmental variables in poetry search.

1reaction
silenc3rcommented, Dec 6, 2018

I’m getting the same ImportError and I’m not using any proxy.

Edit: traceback (poetry init -vvv)

Would you like to define your dependencies (require) interactively? (yes/no) [yes] 



Search for package: beautifulsoup4

                                                                                                                       
[ImportError]                                                                                           
cannot import name 'LegacyRepository' from 'poetry.repositories.legacy_repository' (/home/dawid/.local/lib/python3.  
7/site-packages/poetry/repositories/legacy_repository.py)                                                            
                                                                                                                       
Exception trace:
 /home/dawid/.local/lib/python3.7/site-packages/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /home/dawid/.local/lib/python3.7/site-packages/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /home/dawid/.local/lib/python3.7/site-packages/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /home/dawid/.local/lib/python3.7/site-packages/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /home/dawid/.local/lib/python3.7/site-packages/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /home/dawid/.local/lib/python3.7/site-packages/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /home/dawid/.local/lib/python3.7/site-packages/poetry/console/commands/init.py in handle() at line 126
   self._determine_requirements(self.option("dependency"))
 /home/dawid/.local/lib/python3.7/site-packages/poetry/console/commands/init.py in _determine_requirements() at line 172
   matches = self._get_pool().search(package)
 /home/dawid/.local/lib/python3.7/site-packages/poetry/repositories/pool.py in search() at line 73
   from .legacy_repository import LegacyRepository
 /home/dawid/.local/lib/python3.7/site-packages/poetry/repositories/legacy_repository.py in <module>() at line 33
   from poetry.masonry.publishing.uploader import wheel_file_re
 /home/dawid/.local/lib/python3.7/site-packages/poetry/masonry/__init__.py in <module>() at line 10
   from .builder import Builder
 /home/dawid/.local/lib/python3.7/site-packages/poetry/masonry/builder.py in <module>() at line 1
   from .builders import CompleteBuilder
 /home/dawid/.local/lib/python3.7/site-packages/poetry/masonry/builders/__init__.py in <module>() at line 1
   from .complete import CompleteBuilder
 /home/dawid/.local/lib/python3.7/site-packages/poetry/masonry/builders/complete.py in <module>() at line 4
   import poetry.poetry
 /home/dawid/.local/lib/python3.7/site-packages/poetry/poetry.py in <module>() at line 18
   from .repositories.legacy_repository import LegacyRepository

Edit2: this seems to be fixed in 750e31de98b84e294ac6c5798ad8c4656be9dd2e cc @mulcahys

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Search for package" during poetry init does not work ...
Issue. When running poetry init in an environment behind a corporate proxy, and attempting to interactively resolve dependencies, it times out ...
Read more >
How to get pip to work behind a proxy server [duplicate]
The pip's proxy parameter is, according to pip --help , in the form scheme://[user:passwd@]proxy.server:port. You should use the following:
Read more >
Commands | Documentation
Commands You've already learned how to use the command-line interface to do some things. This chapter documents all the available commands.
Read more >
Private packages with CodeArtifact and Poetry, a ... - Jason Stitt
AWS CodeArtifact acts as a private package repository for several languages - including a private PyPI service. With a little bit of setup, ......
Read more >
Installation - Prefect 2 - Coordinating the world's dataflows
The following sections describe how to install Prefect in your development or execution environment. Installing the latest version¶. Prefect is published as a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found