0

I looked at the previous questions on this topic, but they don't seem to cover this odd issue.

I had a 2.7.x based virtualenv at ~/GP for an older version of my Django installation. However, I moved this to ~/GP_old and moved a new Django installation to ~/GP along with its associated virtualenv based on Python 3.5.x.

However, I noticed that the despite being in the virtualenv with the correct Python version, python still calls the 2.7.x version. Very strange.

Using which shows that despite being in the activated virtualenv, python refers to the system-wide version (2.7.x). Is the virtualenv bound to the location one created it in (in my case this was ~/GP_beta)? If so, how do I update it?

I could delete the virtualenv and create a new version and reinstall my packages as well, but in some cases it seems smart to be able to fix it.

Activating virtualenv and checking python version:

mint@mint-VirtualBox ~/GP $ source env/bin/activate
(env) mint@mint-VirtualBox ~/GP $ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Verifying the version in the virtualenv is actually the correct one:

(env) mint@mint-VirtualBox ~/GP $ cd env/bin
(env) mint@mint-VirtualBox ~/GP/env/bin $ ls -la
total 3736
drwxr-xr-x 3 mint mint    4096 Aug  8 05:53 .
drwxr-xr-x 4 mint mint    4096 Aug  8 05:53 ..
-rw-r--r-- 1 mint mint    2081 Aug  8 05:53 activate
-rw-r--r-- 1 mint mint    1023 Aug  8 05:53 activate.csh
-rw-r--r-- 1 mint mint    2221 Aug  8 05:53 activate.fish
-rw-r--r-- 1 mint mint    1137 Aug  8 05:53 activate_this.py
-rwxr-xr-x 1 mint mint     286 Aug  8 05:53 django-admin
-rwxr-xr-x 1 mint mint     145 Aug  8 05:53 django-admin.py
-rwxr-xr-x 1 mint mint     253 Aug  8 05:53 easy_install
-rwxr-xr-x 1 mint mint     253 Aug  8 05:53 easy_install-3.5
-rwxr-xr-x 1 mint mint     225 Aug  8 05:53 pip
-rwxr-xr-x 1 mint mint     225 Aug  8 05:53 pip3
-rwxr-xr-x 1 mint mint     225 Aug  8 05:53 pip3.5
drwxr-xr-x 2 mint mint    4096 Aug  8 05:53 __pycache__
lrwxrwxrwx 1 mint mint       9 Aug  8 05:53 python -> python3.5
lrwxrwxrwx 1 mint mint       9 Aug  8 05:53 python3 -> python3.5
-rwxr-xr-x 1 mint mint 3759688 Aug  8 05:53 python3.5
-rwxr-xr-x 1 mint mint    2340 Aug  8 05:53 python-config
-rwxr-xr-x 1 mint mint     232 Aug  8 05:53 wheel

Which python installation does python point to?

(env) mint@mint-VirtualBox ~/GP/env/bin $ which python
/usr/bin/python
CoderGuy123
  • 6,219
  • 5
  • 59
  • 89
  • I believe that when you move a new virtualenv into position like this, it must have exactly the same path as the old one. i.e., GP_beta might be embedded somewhere in a pathname in virtualenv and could be the problem. – alan Aug 15 '16 at 21:11
  • 1
    You seem to be right. `virtualenv` apparently uses absolute paths by default and thus break when moved. http://stackoverflow.com/questions/6628476/renaming-a-virtualenv-folder-without-breaking-it I voted to close as duplicate. The solution by http://stackoverflow.com/a/16683703/3980197 worked for me. – CoderGuy123 Aug 15 '16 at 21:16

0 Answers0