Search code examples
pythonvirtualenvwrapper

How can I set the path for python3 properly?


$ echo $PATH
/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

So /usr/local/bin is in my path.

when I do `which python3'

/usr/local/bin/python3

When I then try to create a virtualenv

mkvirtualenv py3000 --python=python3

The executable /Users/misdirectedpuffin/python3 (from --python=/Users/misdirectedpuffin/python3) does not exist

Virtualenv works when using the default python ie mkvirtualenv testenv' and when doing 'mkvirtualenv py3000 --python=/usr/local/bin/python3

It seems to be looking in $HOME for python3. How can I correct this?

** edit **

I can also set export python3=/usr/local/bin/python3 in bash_profile, then call $python3 with --python=$python3, but what I really want is --python=python3 without the dollar sign.


Solution

  • After doing brew doctor, I was advised the following:

    Warning: /usr/local/share/python is not needed in PATH.
    Formerly homebrew put Python scripts you installed via `pip` or `pip3`
    (or `easy_install`) into that directory above but now it can be removed
    from your PATH variable.
    Python scripts will now install into /usr/local/bin.
    You can delete anything, except 'Extras', from the /usr/local/share/python
    (and /usr/local/share/python3) dir and install affected Python packages
    anew with `pip install --upgrade`.
    
    Warning: /usr/bin occurs before /usr/local/bin
    This means that system-provided programs will be used instead of those
    provided by Homebrew. The following tools exist at both paths:
    

    After making these changes, I was able to mkvirtualenv py3000 -p python3