PowerShell中的virtualenv? [英] virtualenv in PowerShell?

查看:54
本文介绍了PowerShell中的virtualenv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各位pythonistas,您好,在PowerShell 中使用virtualenv 时似乎有问题.

Hi fellow pythonistas, there seems to be a problem when virtualenv is used in PowerShell.

当我尝试在 PowerShell 中激活我的环境时,例如..

When I try to activate my environment in PowerShell like..

>环境/脚本/激活

……没有任何反应.(shell 提示符以及 PATH 环境变量应该已更改.)

.. nothing happens. (the shell prompt should have changed as well as the PATH env. variable .)

我猜问题是 PowerShell 生成了一个新的 cmd.仅用于运行 activate.bat 的过程,从而在完成后将 activate.bat 对外壳所做的更改呈现为死机.

I guess the problem is that PowerShell spawns a new cmd. process just for running the activate.bat thus rendering the changes activate.bat does to the shell dead after it completes.

您有解决此问题的方法吗?(我现在坚持使用 cmd.exe)

Do you have any workarounds for the issue? (I'm sticking with cmd.exe for now)

推荐答案

更新: 以下答案已过时.现在,只需使用 activate.ps1(而不是 activate.bat)从 Powershell 环境中激活.

Update: The answer below is out of date. Now, just use activate.ps1 (rather than activate.bat) to activate from a Powershell environment.

这里'sa 帖子,其中包含一个 Powershell 脚本,该脚本允许您运行批处理文件,这些文件会持续修改其环境变量.该脚本将任何环境变量更改传播回调用 PowerShell 环境.

Here's a post which contains a Powershell script which allows you to run batch files that persistently modify their environment variables. The script propagates any environment variable changes back to the calling PowerShell environment.

这篇关于PowerShell中的virtualenv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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