尝试在 Windows 上创建虚拟环境时 VS Code 出现错误

发布于 2025-01-10 05:15:28 字数 751 浏览 3 评论 0原文

我正在尝试在 VS code 中创建一个虚拟环境来制作 Flask 应用程序。当我在 VS code 终端 pip install virtualenv 中运行命令后,所有内容都会下载,但出现错误警告:脚本 virtualenv.exe 安装在

C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

然后当我尝试使用此命令创建虚拟环境时命令 virtualenv env 我收到错误

virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I am trying to create a virtual environment in VS code to make a flask app. After I run the command in the VS code terminal pip install virtualenv everything downloads find but I get the error WARNING: The script virtualenv.exe is installed in

C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Then when I try to create my virtual environment by using this command virtualenv env I get the error

virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

我的影子我的梦 2025-01-17 05:15:28

来自 使用 pip 和虚拟环境安装包< /a>

如果您使用的是 Python 3.3 或更高版本,则 venv 模块是
创建和管理虚拟环境的首选方式。文夫是
包含在Python标准库中,不需要额外的
安装。

python -m venv venv

要运行脚本,只需键入。无需输入完整位置:

./venv/Scripts/activate

From Installing packages using pip and virtual environments

If you are using Python 3.3 or newer, the venv module is the
preferred way to create and manage virtual environments. venv is
included in the Python standard library and requires no additional
installation.

python -m venv venv

To run the scripts just type. No need to put in the complete location:

./venv/Scripts/activate
梨涡 2025-01-17 05:15:28

您使用的是 Windows 应用商店中的 Python 吗?你最好避免它。

您可以从官方网站下载Python。

然后通过venv创建虚拟环境。

您可以参考官方文档了解更多详细信息创建的虚拟环境。

Are you using Python from the Windows Store? You'd better avoid it.

You can download the python from the official site.

And then create the virtual environment through venv.

You can refer to official docs for more details of the virtual environment created.

白色秋天 2025-01-17 05:15:28

发生这种情况是因为目录(如您所提到的)

C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.

未添加到您的路径中

考虑此链接添加到 Windows 10 上的 PATH 并将目录添加到 PATH。
它会解决你的问题。
我也遇到了同样的问题,按照上面的方法解决了。

This is happening because the directory (as mentioned by you)

C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.

is not added to your PATH

Consider this link Add to the PATH on Windows 10 and add the directory to the PATH.
It's gonna solve your problem.
The same issue happened to me it solve it as said above.

一杯敬自由 2025-01-17 05:15:28

转到 cmd 然后输入:

PATH=C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts

在本例中,这是路径,但在您的路径中可能会有所不同
因此只需键入警告中指定的路径即可。

我也遇到了这个问题,花了三个多小时解决这个问题。

Go to cmd and then type:

PATH=C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts

in this case this is the path but it might be different in yours
so just type the path that is specified in the warning.

I also had this issue and spend more than three hours fixing this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文