Frank Harland
Frank Harland

Reputation: 29

Virtual environment pip points to older version

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..

Upvotes: 0

Views: 859

Answers (2)

Alberto
Alberto

Reputation: 1408

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

Upvotes: 2

Frank Harland
Frank Harland

Reputation: 29

(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...

Upvotes: 0

Related Questions