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

后端 未结 9 1343

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:18

    list out the installed packages in the virtualenv

    step 1:

    workon envname

    step 2:

    pip freeze

    it will display the all installed packages and installed packages and versions

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

    In Python3

    pip list
    

    Empty venv is

    Package    Version
    ---------- ------- 
    pip        19.2.3 
    setuptools 41.2.0
    

    To start a new environment

    python3 -m venv your_foldername_here
    

    Activate

    cd your_foldername_here
    source bin/activate
    

    Deactivate

    deactivate
    

    You can also stand in the folder and give the virtual environment a name/folder (python3 -m venv name_of_venv).

    Venv is a subset of virtualenv that is shipped with Python after 3.3.

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

    In my case the flask version was only visible under so I had to go to C:\Users\\AppData\Local\flask\venv\Scripts>pip freeze --local

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

    You can list only packages in the virtualenv by pip freeze --local or pip list --local. This option works irrespective of whether you have global site packages visible in the virtualenv.

    Note that restricting the virtualenv to not use global site packages isn't the answer to the problem, because the question is on how to separate the two lists, not how to constrain our workflow to fit limitations of tools.

    Credits to @gvalkov's comment here. Cf. also this issue.

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

    why don't you try pip list

    Remember I'm using pip version 19.1 on python version 3.7.3

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

    If you're still a bit confused about virtualenv you might not pick up how to combine the great tips from the answers by Ioannis and Sascha. I.e. this is the basic command you need:

    /YOUR_ENV/bin/pip freeze --local
    

    That can be easily used elsewhere. E.g. here is a convenient and complete answer, suited for getting all the local packages installed in all the environments you set up via virtualenvwrapper:

    cd ${WORKON_HOME:-~/.virtualenvs}
    for dir in *; do [ -d $dir ] && $dir/bin/pip freeze --local >  /tmp/$dir.fl; done
    more /tmp/*.fl
    
    0 讨论(0)
提交回复
热议问题