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

Can no longer install via python code #7204

Closed
cleppanen opened this issue Oct 14, 2019 · 2 comments
Closed

Can no longer install via python code #7204

cleppanen opened this issue Oct 14, 2019 · 2 comments
Labels
auto-locked Outdated issues that have been locked by automation resolution: no action When the resolution is to not do anything type: support User Support

Comments

@cleppanen
Copy link

Environment

  • pip version:19.3
  • Python version: 3.6.7
  • OS: Ubuntu 18.04
  • Using python3-venv to create a virtual environment.

Description
As of pip version 19.3, I am no longer able to use the following code snippet to import libraries on the fly in my python project. I receive the error TypeError: 'module' object is not callable

from pip._internal import main as pip

pip(['install', 'libnamehere'])

This similar code works in 19.2, without error.

Expected behavior
The library installs cleanly into the current environment, with no issue.
How to Reproduce

  • Install pip version 19.3
  • Use the code snippet above, and replace libnamehere with any python library.
  • run the code

Output

TypeError: 'module' object is not callable

We can, and probably will pin pip to just run as 19.2 for now, but wanted the team to be aware of this loss of functionality.

If there is a new method, or a better preferred method from the one I posted above in my snippet, I'll take that as feedback as well.

Thank you.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Oct 14, 2019
@chrahunt
Copy link
Member

Hello. Thanks for trying the latest release and reporting your experience!

As mentioned in the docs, importing and running pip in that way is unsupported. The documentation also has a few options for running pip in your code, for example:

subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'my_package'])

@chrahunt chrahunt added resolution: no action When the resolution is to not do anything S: awaiting response Waiting for a response/more information type: support User Support labels Oct 14, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Oct 14, 2019
@cleppanen
Copy link
Author

Indeed it is right there, in the documentation, to which I must've missed all this time.

Thank you, @chrahunt for this! Will implement and we can close this ticket.

Thanks again!

@no-response no-response bot removed the S: awaiting response Waiting for a response/more information label Oct 14, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Nov 13, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation resolution: no action When the resolution is to not do anything type: support User Support
Projects
None yet
Development

No branches or pull requests

3 participants