简体   繁体   English

如何在Mac命令行中返回python虚拟环境

[英]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.

相关问题 如何在命令行上的虚拟环境中的python测试中打印变量的内容 - How to print the content of a variable in python testing within a virtual environment on command line 如何使用命令行在 Visual Studio Code 中为 python 设置虚拟环境 - How to setup a virtual environment for python in Visual Studio Code using the command line 如何在 Mac 上使用 anaconda 虚拟环境运行 python 脚本 - How to run a python script using an anaconda virtual environment on mac 如何在 mac 上的 python 虚拟环境中安装底图? - How can I install basemap in a python virtual environment on mac? 如何从 Mac 上的 Python 虚拟环境调用 MATLAB 库 - How to call MATLAB library from Python virtual environment on Mac 如何将 Python 虚拟环境库从 miniforge 放回 anaconda? - How to put Python virtual environment base back from miniforge to anaconda? VSCode 未检测到 Mac OS 上的 Python 虚拟环境 - VSCode not detecting Python Virtual Environment on Mac OS 如何使用Python在虚拟环境中运行命令 - How to run a command inside virtual environment using Python 如何在Mac上使用brew的虚拟环境中添加PYTHONPATH? - How to add a PYTHONPATH in a virtual environment with brew on a Mac? 如何使用 python 命令在 MAC 上获取 UUID? - How to get UUID on MAC with python command?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM