Use subprocess.call([sys.executable, '-m', 'pip', ...]) to call pip
See original GitHub issueDo not use “os.system('pip install {0}=={1}'.format(pkg, version))
”.
Instead, I suggest doing as follows:
import pip
pip.main(['install', '{0}=={1}'.format(pkg, version)])
Sorry for my poor English.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
python - Should I use pip.main() or subprocess.call() to invoke ...
It depends. pip is undocumented and may not be backwards compatible. I recommend using subprocess instead ...
Read more >How to Install Python Packages using a Script - ActiveState
How to Install Python Packages using a Script ; # implement pip as a subprocess: subprocess.check_call([sys.executable, '-m', 'pip', 'install', ' ...
Read more >Python install package - ProgramCreek.com
This page shows Python code examples for install package.
Read more >How to Run Pip From The Python Interactive Shell
This function call simulates running a command from the Terminal or Command Prompt window, except it's now done from Python code. sys.executable ......
Read more >subprocess — Subprocess management — Python 3.11.1 ...
For more advanced use cases, the underlying Popen interface can be used directly. subprocess.run(args, *, stdin=None, input=None, stdout=None, stderr=None, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually, what you’re supposed to do is this:
welcome, I commented because i could not find a proper example of adding pip options. my challenge is that am using a company proxy,so i needed the extra options.