0

Python 3.5, later 3.6 installed with homebrew and django with virtual environments with pip.

Somehow the normal env shows version 3.6 of Python and 3.5 whithin virtual environment, like this:

MacBook-Pro-Frank:~ Frank$ pip3 --version
pip 9.0.3 from /usr/local/lib/python3.6/site-packages (python 3.6)

MacBook-Pro-Frank:~ Frank$ pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.
bash-3.2$ . /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS/bin/activate

(Frank-ZvIKOxyS) bash-3.2$ pip3 --version
pip 9.0.1 from /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS/lib/python3.5/site-packages (python 3.5)
(Frank-ZvIKOxyS) bash-3.2$ 

Could someone please tell me how to begin repairing this. Searching for over 30 hours for this..

I'm on a Macbook macOS 10.13.4.

I know it's not a programming question but I would like to start programming and this is a prerequisite..

  • It's a programming question — it's a question about programming tools, perfectly legal at SO, nothing to worry about. But what exactly do you want to upgrade? Python or pip? – phd May 03 '18 at 15:59
  • I want the same versions of pip in my virtual env as in the normal environment: 9.0.3 that is linked to Python 3.6. Django does not work in my virtual env now. – Frank Harland May 03 '18 at 20:25
  • Possible duplicate of [How do I update pip itself from inside my virtual environment?](https://stackoverflow.com/questions/15221473/how-do-i-update-pip-itself-from-inside-my-virtual-environment) – phd May 03 '18 at 21:59

2 Answers2

2

If you want to use a specific version of python when creating the virtualenv you should use the --python flag:

virtualenv --python=/usr/local/lib/python3.6 <path/to/new/virtualenv/>

If you are using pipenv as this is the case just use:

pipenv --python 3.6
Alberto
  • 1,348
  • 2
  • 14
  • 28
  • Hi thanks very much for your reply. I just want the versions to be the same in the standard situation as in the virtual environment (3.6 for Python /9.0.3 for pip). I use pipenv shell as the command to start the virtual environment as you can see. – Frank Harland May 03 '18 at 20:29
  • I haven't tried it but maybe this helps. From the official documentation of pipenv [https://docs.pipenv.org/basics/#specifying-versions-of-python](https://docs.pipenv.org/basics/#specifying-versions-of-python) – Alberto May 04 '18 at 06:52
  • I'm glad to hear that, can you set this answer as correct answer then? – Alberto May 06 '18 at 16:07
  • No, because this is in a comment I can't mark it as best answer, that's why I wrote it out in a new reaction mentioning you as solver. Thanks again. – Frank Harland May 07 '18 at 18:19
0
(Frank-ZvIKOxyS) bash-3.2$ exit
exit
MacBook-Pro-Frank:~ Frank$ pipenv --python 3.6
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Using /usr/local/bin/python3.6m (3.6.5) to create virtualenv…
Running virtualenv with interpreter /usr/local/bin/python3.6m
Using base prefix '/usr/local/Cellar/python/3.6.5/Frameworks/Python.framework/Versions/3.6'
New python executable in /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS/bin/python3.6

Also creating executable in /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS

Testing:

MacBook-Pro-Frank:~ Frank$ pipenv shell
Spawning environment shell (/bin/bash). Use 'exit' to leave.
bash-3.2$ . /Users/Frank/.local/share/virtualenvs/Frank-ZvIKOxyS/bin/activate
Frank-ZvIKOxyS) bash-3.2$ python --version 
Python 3.6.5
(Frank-ZvIKOxyS) bash-3.2$ pip --version
pip 10.0.1 from /Users/Frank/.local/share/virtualenvs/Frank- 
ZvIKOxyS/lib/python3.6/site-packages/pip (python 3.6)
(Frank-ZvIKOxyS) bash-3.2$

Thanks to Alberto, this solved my puzzle.

Puzzling on...