虚拟环境"workon"不起作用 [英] virtualenv "workon" doesn't work

查看:42
本文介绍了虚拟环境"workon"不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为项目创建了virtualenv环境."workon projectname"工作并激活了环境,但是当我关闭笔记本电脑后,它开始无法工作.有人可以告诉我如何解决这个问题吗?

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?

推荐答案

由于我没有足够的声誉来发表评论,因此我将尝试尝试一个答案,因为我认为我知道问题出在哪里.

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.

通常发生这种情况是因为virtualenvwrapper是一个shell脚本,在您访问"workon"和"mkvirtualenv"之类的命令之前,需要先获取该脚本.我的 virtualenvwrapper.sh 脚本安装在/usr/local/bin 中,因此我只需运行:

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:

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

通常我将此行添加到我的〜/.bashrc 〜/.profile 文件中,以确保这些命令在Shell中始终可用.您可以在安装文档中找到有关设置的更多特定信息.没有源文件肯定会导致命令在关闭后停止工作.

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.

这篇关于虚拟环境"workon"不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆