Dreamhost 上的 virtualenv:如何确保始终使用我的环境
我最近开始使用 virtualenv 并尝试安装我自己的软件包,例如 PIL 等。
我想知道我需要做什么才能确保一旦激活环境,它就会保持激活状态或至少被使用,而不是系统Python。
到目前为止,我已经在我的主目录中创建了环境,并且可以激活和停用它。我只需要让它永久化。
如果您需要更多信息,请告诉我。
I recently started with virtualenv and was trying to install my own packages like PIL etc.
I wanted to know what do I need to do to make sure once I activate the environment, it remains activated or at least it is used, instead of the system python.
So far I have created the environment in my home directory and can activate and deactivate it. I just need to make it permanent.
Please let me know if you need more information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一般答案是“将虚拟环境的‘bin’目录放在系统默认路径之前”。具体如何执行此操作的具体答案在很大程度上取决于您所使用的操作系统和 shell。然而,由于您使用了术语“主目录”,我将假设您正在使用某种形式的 Unix,并且由于大多数变体默认与 bash 兼容,因此您可能只需要添加行“将 /path/to/my/vritual/py/bin/activate" 复制到您的 ~/.bashrc 文件中。添加该行,注销并重新登录,您的虚拟环境应该是您的默认环境。
The general answer is "Place the 'bin' directory of the virtual environment in your path ahead of the system default". The specific answer on exactly how to do this depends rather dramatically on which OS and and shell you're using. Since you used the term "home directory", however, I'm going to assume you're using some form of Unix and, as most variants default to something bash-compatible, you probably just need to add the line "source /path/to/my/vritual/py/bin/activate" to your ~/.bashrc file. Add that line, logout, and log back in and your virtual environment should be your default.
将其添加到文件的顶部:
Add this to the top of your file: