重定位的virtualenv(可重定位)并不指向正确的python

时间:2017-09-28 09:19:08

标签: python virtualenv

创建并激活Virtualenv

vikram@vikram-XPS-15-9530:~/test_dirs$ virtualenv venv_test 
New python executable in /home/vikram/test_dirs/venv_test/bin/python Installing setuptools, pip, wheel...done. 

vikram@vikram-XPS-15-9530:~/test_dirs$ source venv_test/bin/activate
(venv_test) vikram@vikram-XPS-15-9530:~/test_dirs$ which python  
/home/vikram/test_dirs/venv_test/bin/python
(venv_test) vikram@vikram-XPS-15-9530:~/test_dirs$ deactivate

使virtualenv可重定位:

vikram@vikram-XPS-15-9530:~/test_dirs$ virtualenv --relocatable venv_test
Making script /home/vikram/test_dirs/venv_test/bin/pip2 relative
Making script /home/vikram/test_dirs/venv_test/bin/python-config relative
Making script /home/vikram/test_dirs/venv_test/bin/pip2.7 relative
Making script /home/vikram/test_dirs/venv_test/bin/pip relative
Making script /home/vikram/test_dirs/venv_test/bin/easy_install-2.7 relative
Making script /home/vikram/test_dirs/venv_test/bin/easy_install relative
Making script /home/vikram/test_dirs/venv_test/bin/wheel relative

vikram@vikram-XPS-15-9530:~/test_dirs$ source venv_test/bin/activate
(venv_test) vikram@vikram-XPS-15-9530:~/test_dirs$ which python
/home/vikram/test_dirs/venv_test/bin/python
(venv_test) vikram@vikram-XPS-15-9530:~/test_dirs$ deactivate

移动virtualenv:

vikram@vikram-XPS-15-9530:~/test_dirs$ mv venv_test test_dir2/
vikram@vikram-XPS-15-9530:~/test_dirs$ cd test_dir2/
vikram@vikram-XPS-15-9530:~/test_dirs/test_dir2$ ls
venv_test
vikram@vikram-XPS-15-9530:~/test_dirs/test_dir2$ source venv_test/bin/activate

错误的python位置

(venv_test) vikram@vikram-XPS-15-9530:~/test_dirs/test_dir2$ which python
/usr/bin/python

按照上面的步骤看起来像virtualenv没有正确移动一切。如果有问题请告诉我。我期待“哪个python”将显示来自同一个virtualenv的python路径。

0 个答案:

没有答案