script.pip() does not work with use_module=True
See original GitHub issueEnvironment
- pip version: 20.1.dev0
- Python version: 3.6.9
- OS: Linux Mint Debian Edition
Description
While I was working on this #7810, I found that when I use script.pip("freeze")
with use_module
as True
which is the default behaviour, it does not show any package list, while when I explicitly specify use_module
as False
, it does.
I found that the difference is the way the command is invoked. With use_module=True
, it is invoked as python -m pip freeze
and with use_module=False
, it is invoked as pip freeze
.
Expected behavior
Both ways, it should show up the package list.
How to Reproduce
A test can be written to verify this behaviour.
def test_pip_script(script):
assert script.pip("freeze").stdout == script.pip("freeze", use_module=False).stdout
Output
___________________________________________________ test_pip_script ___________________________________________________
[gw4] linux -- Python 3.6.9 /home/gutsytechster/Documents/Projects/Open-Source-Projects/pip/.tox/py36/bin/python
script = <tests.lib.PipTestEnvironment object at 0x7f696adfc8d0>
def test_pip_script(script):
> assert script.pip("freeze").stdout == script.pip("freeze", use_module=False).stdout
E AssertionError: assert '' == 'apipkg==1.5\natomicwrites==...zeug==0.16.0\nzipp==3.0.0\n'
E + apipkg==1.5
E + atomicwrites==1.3.0
E + attrs==19.3.0
E + cffi==1.14.0
E + coverage==5.0.3
E + cryptography==2.8
E + csv23==0.1.6
E + execnet==1.7.1
E + freezegun==0.3.15
E + importlib-metadata==1.5.0
E + mock==4.0.1
E + more-itertools==8.2.0
E + pluggy==0.13.1
E + pretend==1.0.9
E + py==1.8.1
E + pycparser==2.19
E + pytest==3.8.2
E + pytest-cov==2.8.1
E + pytest-forked==1.1.3
E + pytest-rerunfailures==6.0
E + pytest-timeout==1.3.4
E + pytest-xdist==1.27.0
E + python-dateutil==2.8.1
E + PyYAML==5.3
E + scripttest==1.3
E + six==1.14.0
E + virtualenv==16.7.10
E + Werkzeug==0.16.0
E + zipp==3.0.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
'pip' is not recognized - python - Stack Overflow
This error shows up on windows when one tries to use pip in the command prompt. To solve this error on windows, you...
Read more >wheel: script with multiprocessing doesn't work on Windows ...
The wrappers used when installing from a wheel are based on distlib's ScripMaker module, but with a modified template (see https://github.com/pypa/pip/blob/ ...
Read more >__main__ — Top-level code environment — Python 3.11 ...
When this is done, pip inserts the function call into a template script, where the return value of main is passed into sys.exit()...
Read more >Working with the AWS CDK in Python
pip freeze captures the current versions of all modules installed in your Python virtual environment, which can be useful when bundling up a...
Read more >How to Install Python Packages using a Script - ActiveState
Use of a Python script to run pip to install a package is not supported by the Python Packaging Authority (PyPA) for the...
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
Should be, yea. It might also be in the isolate fixture, so that would be worth taking a look at.
Thanks for filing a new issue for this!
My initial response is here: https://github.com/pypa/pip/pull/7810#issuecomment-599191853. Please do follow up on that here. 😃