1

There has been quite a few installations of Python and Anacondas on my Mac over the years, and to some extent these have been neglected and I suspect now resurface and cause me issues.

I'd like to setup a virtualenv environment and did a pip install virtualenv. I'd like to create a new environement, Django18, for Django1.8, but after executing the command virtualenv Django18 I receive an error message:

OSError: Command ~/Desktop/Django18/bin/python - setuptools pip wheel failed with error code 1

bash_profile

# added by Anaconda2 4.2.0 installer
export PATH="~/anaconda2/bin:$PATH"

command: which python

~/anaconda2/bin/python

In /usr/bin/:

-rwxr-xr-x     2 root   wheel     58416 Jul 15  2015 python
-rwxr-xr-x     5 root   wheel       925 Sep 10  2014 python-config
lrwxr-xr-x     1 root   wheel        75 Nov  9  2014 python2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
lrwxr-xr-x     1 root   wheel        82 Nov  9  2014 python2.6-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6-config
lrwxr-xr-x     1 root   wheel        75 Nov  9  2014 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x     1 root   wheel        82 Nov  9  2014 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x     2 root   wheel     58416 Jul 15  2015 pythonw
lrwxr-xr-x     1 root   wheel        76 Nov  9  2014 pythonw2.6 -> ../../System/Library/Frameworks/Python.framework/Versions/2.6/bin/pythonw2.6
lrwxr-xr-x     1 root   wheel        76 Nov  9  2014 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

.profile

export PATH="/opt/local/lib/gmt4/bin:$PATH"
export PATH="~/teqc:$PATH"
export PATH="/usr/local/runpkr000:$PATH"
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# MacPorts Installer addition on 2015-04-02_at_16:40:23: adding an appropriate PATH variable for use with MacPorts.
# export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.

# added by Anaconda 2.3.0 installer
# export PATH="~/anaconda/bin:$PATH"

I suspect there needs to be some clearing up with this, but how can I resolve this error message and get virtualenv to work as expected? I have tried several methods already out there, but it's difficult for me to recognise what exactly in my case is causing this issue, before applying a potential remedy.


/opt/local/bin (is that macports installation)?:

lrwxr-xr-x    1 root  admin       24 Oct  9  2016 python -> /opt/local/bin/python2.7
lrwxr-xr-x    1 root  admin       31 Oct  9  2016 python-config -> /opt/local/bin/python2.7-config
lrwxr-xr-x    1 root  admin       73 Dec 14  2014 python2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x    1 root  admin       80 Dec 14  2014 python2.7-config -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x    1 root  admin       25 Oct  9  2016 pythonw -> /opt/local/bin/pythonw2.7
lrwxr-xr-x    1 root  admin       74 Dec 14  2014 pythonw2.7 -> /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

/usr/Local/bin

lrwxr-xr-x   1 root    staff        69 Dec 12  2012 python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3
lrwxr-xr-x   1 root    staff        72 Dec 12  2012 python3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3-32
lrwxr-xr-x   1 root    staff        76 Dec 12  2012 python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3-config
lrwxr-xr-x   1 root    staff        71 Dec 12  2012 python3.3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3
lrwxr-xr-x   1 root    staff        74 Dec 12  2012 python3.3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3-32
lrwxr-xr-x   1 root    staff        78 Dec 12  2012 python3.3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3-config
lrwxr-xr-x   1 root    staff        72 Dec 12  2012 python3.3m -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m
lrwxr-xr-x   1 root    staff        79 Dec 12  2012 python3.3m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3m-config
lrwxr-xr-x   1 root    staff        70 Dec 12  2012 pythonw3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3
lrwxr-xr-x   1 root    staff        73 Dec 12  2012 pythonw3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3-32
lrwxr-xr-x   1 root    staff        72 Dec 12  2012 pythonw3.3 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3
lrwxr-xr-x   1 root    staff        75 Dec 12  2012 pythonw3.3-32 -> ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3.3-32

import sys sys.path

~/anaconda2/lib/python27.zip
~/anaconda2/lib/python2.7
~/anaconda2/lib/python2.7/plat-darwin
~/anaconda2/lib/python2.7/plat-mac
~/anaconda2/lib/python2.7/plat-mac/lib-scriptpackages
~/anaconda2/lib/python2.7/lib-tk
~/anaconda2/lib/python2.7/lib-old
~/anaconda2/lib/python2.7/lib-dynload
~/anaconda2/lib/python2.7/site-packages
~/anaconda2/lib/python2.7/site-packages/Sphinx-1.4.6-py2.7.egg
~/anaconda2/lib/python2.7/site-packages/aeosa
~/anaconda2/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg

/opt/local/Library/Frameworks:

Python.framework

/System/Library/Frameworks

Python.framework

EDIT

which python produces :

~/anaconda2/bin/python

which -a python produces :

~/anaconda2/bin/python
/usr/bin/python

They're not the same. But then after deleting python installations in:

/opt/local/bin
/usr/Local/bin
/usr/bin

and using rm -rf python* and sudo rm -rf python* in

/opt/local/Library/Frameworks

the which outputs then become the same.

I've realised that the which python command actually refers to what is written in the .bash_profile file and not .profile (priority to .bash_profile).

In any case I commented out the $PATH in my .bash_profile, so forcing the environment variables only to be used in the .profile file. Then source ~/.bash_profile.

In my .profile I added:

export PATH="/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages:$PATH

Then source ~/.profile

However after which python I still get:

~/anaconda2/bin/python

This is getting a bit frustrating as even changing the relevant files and deleting certain python installations, the result is still the same :-/

pymat
  • 1,090
  • 1
  • 23
  • 45
  • Anaconda comes with a command line tool called 'conda' which makes managing virtual environments alot easier. Have you tried `conda create -n python=3.6`? (replace `3.6` with the python version of your choice). Environments created with conda will be installed to `/envs/` by default. – orangeInk Aug 03 '17 at 13:11

3 Answers3

2

For me the best workaround was to check first in which -a python, in my case there are two occurrences:

~/anaconda2/bin/python
/usr/bin/python

For some unknown reason, the virtualenv command doesn't seem to like the anaconda installation of python, so use instead:

virtualenv -p /usr/bin/python2.7 my_environment
pymat
  • 1,090
  • 1
  • 23
  • 45
1

I had the same error but then i just realized that i was trying to create a virtualenv folder (C:/myname/virtual_folder) at the same directory level as was my Python installation folder (C:/myname/python27) .

So I just created a folder and then inside of it (C:/myname/newfolder/..) i run ("virtualenv virtual_folder") with no issues .

Prometheus
  • 999
  • 2
  • 15
  • 28
0

If you have several disparate installations for python and anaconda, th only thing I can recommend is to just clean up. But also interested what other will tell.

vlad.rad
  • 1,055
  • 2
  • 10
  • 28
  • Cleaning up is what I thought, but I assume it's just not a simple case of delete the Python version that I don't want? Are there other locations too where it is installed...that's also not clear. – pymat Aug 03 '17 at 12:54
  • 1
    not a simple case, sure :) because you probably installed diff. dependencies with diff. clients at diff. locations. I found two posts on SO how to do clean up: 1. https://stackoverflow.com/questions/1909249/how-to-clean-up-my-python-installation-for-a-fresh-start 2. https://stackoverflow.com/questions/14117945/too-many-different-python-versions-on-my-system-and-causing-problems – vlad.rad Aug 03 '17 at 13:03
  • I looked in /opt/local/Library/Frameworks & /System/Library/Frameworks & sys.path & /usr/Local/bin & /opt/local/bin as there are loads more Python installations. NB: Just edited original post. It seems /opt/local/bin could be Macports? Which directories are recommended to delete (what is the normal procedure to remove installations from a directory)? Why is there no $PYTHONPATH ? I assume too from the other threads that nothing from /opt/local/Library/Frameworks nor /System/Library/Frameworks should be deleted, but why is there two instances of Python.framework in these directories? – pymat Aug 04 '17 at 11:31