Pip packages not found - Brewed Python

后端 未结 3 1830
南方客
南方客 2020-12-17 09:42

Running Python 2.7.3, installed with HomeBrew, on a mac.

Installed several packages using PIP, including virtualenv. (Using virtualenv as an example, but NONE of the

相关标签:
3条回答
  • 2020-12-17 10:21

    Download virtualenv.py if your system does not provide virtualenv command:

    curl -L -o virtualenv.py https://raw.github.com/pypa/virtualenv/master/virtualenv.py
    

    First create your virtualenv folder:

     python virtualenv.py venv # venv <-- name of the folder
    

    You need run virtualenv's activate in shell:

     . venv/bin/activate
    

    or

     source venv/bin/activate
    

    This fixes PYTHONPATH and PATH. You do this once per each shell session. Then python command will magically work :)

    Now run pip, packages will be installed in venv.

    More info (disclaimer, I am the author) http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of-python-software-with-virtualenv/

    0 讨论(0)
  • 2020-12-17 10:29

    The problem was that I had not added Python to the system $PATH.

    At the end of the brew install it says (viewable by typing brew info python):

    Executable python scripts will be put in:  
       /usr/local/share/python
    so you may want to put "/usr/local/share/python" in your PATH, too.
    

    So, simply had to open .profile and paste it in, and all packages work.

    Much thanks to MistyM on the Brew IRC channel for pointing that out!

    0 讨论(0)
  • 2020-12-17 10:29

    Quick work flow on creating a Virtual env

    $ mkdir awesomeapp 
    $cd awesomeapp
    $virtualenv venv --distribute
    New python executable in venv/bin/python
    Installing distribute.........done.
    Installing pip................done.
    $source venv/bin/activate
    (venv)$python
    

    One you CD into your directory that's when you're creating your virtual venv folder to store your path.

    You'll now it's active when you see the (venv)

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