virtualenv “workon” doesn't work

孤人 提交于 2020-11-27 02:00:59

问题


I made a virtualenv environment for a project. "workon projectname" worked and activated the environment but after I shut down my laptop it starts not working. Could someone tell me how to fix this?


回答1:


Since I don't have enough reputation to comment I'll simply attempt an answer as I think I know what the issue is.

Firstly, if you could provide more details as to what you mean by "not working" I will edit my answer if need be and attempt to help more.

Typically this happens because virtualenvwrapper is a shell script that needs to be sourced before you have access to commands like "workon" and "mkvirtualenv". My virtualenvwrapper.sh script is installed in /usr/local/bin so I simply run:

$ source /usr/local/bin/virtualenvwrapper.sh

Typically I add this line to my ~/.bashrc or ~/.profile file to ensure these commands are always available in the shell. You can find more specific information for your setup in the Installation Documentation. Not having it sourced would definitely cause the commands to stop working after a shutdown.




回答2:


In my case I need to do the following steps (on Mac OS X 10.11):

I added this line:

source "/Library/Frameworks/Python.framework/Versions/2.7/bin/virtualenvwrapper.sh"

to my ~/.bash_profile

And afterwards, following Eric Scrivner instructions, I created a folder at /opt/ called virtual_env using sudo mkdir /opt/virtual_env

And finally, I run the command sudo chown -R youruser /opt/virtual_env

And than: source ~/.bash_profile



来源:https://stackoverflow.com/questions/29900090/virtualenv-workon-doesnt-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!