0

I'm using virtualenvwrapper. It worked fine on my previous computer, using High Sierra, but I have a new computer with Mojave.

The effect of this seems to be that when I try to install virtualenvwrapper with pip, I get:

Installing collected packages: six, stevedore, virtualenvwrapper
  Found existing installation: six 1.4.1
Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I get the same thing if I try to upgrade six...

If I install with pip3, it works fine.

However, /usr/bin/python is still python2, because that seems to be a thing that no one is changing. So, whenever I try to use virtualenvwrapper, it says:

/usr/bin/python: No module named virtualenvwrapper

I have tried to delete /usr/bin/python, or make it a link to python3 or something, but I don't have permissions for that, even with sudo.

I'm not sure which part of this is the part of the knot I can unravel...

ETA: Actual output from a run:

turlingdrome$ mkvirtualenv testenv -p python3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/brianp/work/venvs/testenv/bin/python3.7
Also creating executable in /Users/brianp/work/venvs/testenv/bin/python
Installing setuptools, pip, wheel...
done.
/usr/bin/python: No module named virtualenvwrapper
turlingdrome$ workon testenv
/usr/bin/python: No module named virtualenvwrapper
/usr/bin/python: No module named virtualenvwrapper
(testenv) turlingdrome$ python
Python 3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
(testenv) turlingdrome$ deactivate
/usr/bin/python: No module named virtualenvwrapper
/usr/bin/python: No module named virtualenvwrapper
turlingdrome$ 

Did it set everything up correctly? I don't know. Normally mkvirtualenv automatically activates the env you just made...

When I set VIRTUALENVWRAPPER_PYTHON, I get:

turlingdrome$ export VIRTUALENVWRAPPER_PYTHON=python3
turlingdrome$ mkvirtualenv test2 -p python3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/brianp/work/venvs/test2/bin/python3.7
Also creating executable in /Users/brianp/work/venvs/test2/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /Users/brianp/work/venvs/test2/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/brianp/work/venvs/test2/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/brianp/work/venvs/test2/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/brianp/work/venvs/test2/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/brianp/work/venvs/test2/bin/get_env_details
/Users/brianp/work/venvs/test2/bin/python3: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
/Users/brianp/work/venvs/test2/bin/python3: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
(test2) turlingdrome$ 
Brian Postow
  • 11,709
  • 17
  • 81
  • 125
  • 1
    `usr/bin/python` should always be python 2.7 that is the systems distribution of python on Mac and should not be changed – Matthew Barlowe Apr 09 '19 at 19:19
  • Right. So then why is virtualenvwrapper trying to use it, when I only have it installed for python3? – Brian Postow Apr 09 '19 at 21:23
  • or alternatively, why can I not install virtualenvwrapper for python2? – Brian Postow Apr 09 '19 at 21:24
  • I would install vitrualenvwrapper for python 3 and then just create python 2.7 environments with it – Matthew Barlowe Apr 09 '19 at 21:29
  • But then it keeps crashing because it keeps trying to run /usr/bin/python for some reason, which doesn't have virtualenvwrapper... – Brian Postow Apr 09 '19 at 21:32
  • Make sure your python3 location is located before /usr/bin/python on your $PATH variable. Without knowing your setup is hard to diagnose this link should be a good guide to making sure worrisome env wrapper is installed properly https://virtualenvwrapper.readthedocs.io/en/latest/install.html – Matthew Barlowe Apr 09 '19 at 21:34
  • But there is no other python. /usr/local/bin/python3 is before /usr/bin/python, but there's no python3 named "python". – Brian Postow Apr 10 '19 at 14:45
  • What exactly are you typing that causes it to crash? If you could put that in the question that would be great along with the full trace of the error code – Matthew Barlowe Apr 10 '19 at 16:13
  • Ok, added a transcript. – Brian Postow Apr 10 '19 at 17:13
  • Is there a reason you are using `virtualenvwrapper` instead of the built-in Python 3 module `venv`? – sloppypasta Apr 10 '19 at 17:14
  • Virtualenvwrapper wraps venv. It lets you have multiple venvs and switch easily between them. – Brian Postow Apr 10 '19 at 17:17
  • Can you run the following and provide output: `which python3` and `which pip3` – sloppypasta Apr 10 '19 at 17:35
  • both are /usr/local/bin (installed by homebrew) – Brian Postow Apr 10 '19 at 17:37
  • I think you need to run `pip3 install virtualenvwrapper` – sloppypasta Apr 10 '19 at 17:37
  • I did that initially. otherwise mkvirtualenv wouldn't have run at all! The python for which virtualenvwrapper isn't installed is /usr/bin/python which is python2.... – Brian Postow Apr 10 '19 at 17:42
  • Well it seems as though it might be installed elsewhere. What is the output of `which mkvirtualenv`? Also, are there any `VIRTUALENV` relevant exports in your shell configuration files? – sloppypasta Apr 10 '19 at 17:44
  • I'll also point out that according to the docs, `virtualenvwrapper` has only been tested up to Python 3.6. It may not work with 3.7 at all. Unless you need 3.7 for something specific, you might consider downgrading to 3.6. – sloppypasta Apr 10 '19 at 17:47
  • mkvirtualenv is a function, not a script, so there's no which... And the version for which there's no virtualenvwrapper is 2.7 – Brian Postow Apr 10 '19 at 18:06
  • `mkvirtualenv` is typically "installed" as an alias in one of your shell configuration files – sloppypasta Apr 10 '19 at 18:27
  • alias mkvirtualenv doesn't show anything either... – Brian Postow Apr 10 '19 at 19:41
  • Try setting this env variable `export VIRTUALENVWRAPPER_VIRTUALENV=/Exact/Path/To/virtualenv` – Matthew Barlowe Apr 11 '19 at 02:16
  • which most likely will be which most likely will be `/usr/local/lib/python3.7/site-packages/virtualenv.py` where you change the python numbers to your version of python – Matthew Barlowe Apr 11 '19 at 02:28
  • @MatthewBarlowe Do I need to do that before I create the virtualenv? It doesn't seem to have changed anything in the workon command... – Brian Postow Jul 08 '19 at 20:25

0 Answers0