[英]How to get back to python virtual environment in mac command line
I am having a bit of difficulty reinitiating my virtual environment on my preprod server on command line. 在命令行上在preprod服务器上重新启动虚拟环境时,我遇到了一些困难。 I think when I quit out of my preprod server the other day, I also quit out of my virtual environment, because now it doesn't say (env) in front of the preprod prompt:
我想有一天,当我退出preprod服务器时,我也退出了虚拟环境,因为现在它在preprod提示符前没有说(env):
Before: (env) SAS@preprod:~$
Now: SAS@preprod:~$
I am logged into my preprod server now, and I have a virtual_environment_command.txt file, and a config file accessible. 我现在已登录到preprod服务器,并且具有virtual_environment_command.txt文件和可访问的配置文件。 I just don't know how to activate either of those documents so I can utilize my virtual environment for testing the code for an api document I'm working on.
我只是不知道如何激活这些文档中的任何一个,因此我可以利用我的虚拟环境来测试我正在处理的api文档的代码。 Thanks!
谢谢!
You have to find the directory where the virtualenv was created. 您必须找到创建virtualenv的目录。 eg when you created it using
virtualenv env
it would create a directory called env
and you can activate it using: 例如,当您使用
virtualenv env
创建它时,它将创建一个名为env
的目录,您可以使用以下方法激活它:
source env/bin/activate
Thank you so much for your responses! 非常感谢您的回复! They were very helpful!
他们非常有帮助! I also ended up clicking the up arrow enough times to figure out what I typed in before to reactivate the venv a few days ago (yes it was a lot of clicking, lol) and found that the following command also proved to fix the problem:
我也结束了单击向上箭头的次数,以弄清楚几天前我键入的内容才能重新激活venv(是的,单击很多,大声笑),并且发现以下命令也可以解决该问题:
SAS@preprod:~$$(cat virtual_environment_command.txt )
And that extra $ is not a typo, it goes the prompt and then $(cat virtual_environment_command.txt) 而且多余的$不是错字,它会提示然后输入$(cat virtual_environment_command.txt)
Thank you again! 再次感谢你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.