How can I make a list of installed packages in a certain virtualenv?

后端 未结 9 1344

You can cd to YOUR_ENV/lib/pythonxx/site-packages/ and have a look, but is there any convenient ways?

pip freeze list all the

相关标签:
9条回答
  • 2020-12-02 12:30

    Calling pip command inside a virtualenv should list the packages visible/available in the isolated environment. Make sure to use a recent version of virtualenv that uses option --no-site-packages by default. This way the purpose of using virtualenv is to create a python environment without access to packages installed in system python.

    Next, make sure you use pip command provided inside the virtualenv (YOUR_ENV/bin/pip). Or just activate the virtualenv (source YOUR_ENV/bin/activate) as a convenient way to call the proper commands for python interpreter or pip

    ~/Projects$ virtualenv --version
    1.9.1
    
    ~/Projects$ virtualenv -p /usr/bin/python2.7 demoenv2.7
    Running virtualenv with interpreter /usr/bin/python2.7
    New python executable in demoenv2.7/bin/python2.7
    Also creating executable in demoenv2.7/bin/python
    Installing setuptools............................done.
    Installing pip...............done.
    
    ~/Projects$ cd demoenv2.7/
    ~/Projects/demoenv2.7$ bin/pip freeze
    wsgiref==0.1.2
    
    ~/Projects/demoenv2.7$ bin/pip install commandlineapp
    Downloading/unpacking commandlineapp
    Downloading CommandLineApp-3.0.7.tar.gz (142kB): 142kB downloaded
    Running setup.py egg_info for package commandlineapp
    Installing collected packages: commandlineapp
    Running setup.py install for commandlineapp
    Successfully installed commandlineapp
    Cleaning up...
    
    ~/Projects/demoenv2.7$ bin/pip freeze
    CommandLineApp==3.0.7
    wsgiref==0.1.2
    

    What's strange in my answer is that package 'wsgiref' is visible inside the virtualenv. Its from my system python. Currently I do not know why, but maybe it is different on your system.

    0 讨论(0)
  • 2020-12-02 12:31

    If you are using pip 19.0.3 and python 3.7.4. Then go for pip list command in your virtualenv. It will show all the installed packages with respective versions.

    0 讨论(0)
  • 2020-12-02 12:31

    .venv/bin/pip freeze worked for me in bash.

    0 讨论(0)
提交回复
热议问题