python - 如何解决 "Error: [Win Error2] The system cannot find the file specified"

标签 python visual-studio python-venv

我想在我的工作区中设置一个 python3 虚拟环境。我有两个版本的python,安装在以下路径:C:\Python\Python27\python2.exe C:\Python\Python38\python3.exe .我已经在 powershell 终端上检查过它们是否已正确安装。
我尝试了命令 python3 -m venv .venv .它创建了一个 .venv文件夹,但我收到以下错误消息:"Error: [Win Error2] The system cannot find the file specified .
我的 IDE 是 Visual Studio Code 1.39.2

此外,Python3 被添加到变量环境中的路径 C:\Python\Python38
我也尝试使用命令 py -3 -m venv .venv ,但后来我得到:

Python 3 not found! Installed Pythons found by C:\WINDOWS\py.exe 
launchers for Windows
No Installed Pythons found

我也已经执行了命令 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process但什么都没有改变。

我的 settings.json 文件:
{ "python;pythonPath": "C:\\Python\\Python38\\python3.exe" }

我的 pyvenv.cfg 文件:
home = C:\Python\Python38
include-system-site-package = false
version = 3.8.0

最佳答案

在这里参加聚会有点晚了,但我遇到了同样的问题,我意识到只有当我在 onedrive 文件夹“C:\Users\username\OneDrive - company\Documents\”中创建一个 venv 时才会发生。
当我将路径更改为 "C:\tmp"时,完全相同的代码起作用了。

不确定为什么会发生这种情况。

关于python - 如何解决 "Error: [Win Error2] The system cannot find the file specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58801279/

相关文章:

python - 创建了一个 PyPI 包并安装,但运行时返回导入错误

python - 多宿主 UDP Python 服务器监听 0.0.0.0

visual-studio - Visual Studio 2012 中的 session /工作集

visual-studio - ReSharper TypeScript 在我的 VS 2015 安装中似乎根本不起作用

python3 -m venv 语法无效

javascript - 如何使用 Selenium Python 在 WordPress 帖子中上传文件?

python - 包含 SQLite 的第一个 Python 版本是什么?

c# - VS2017 和 NUnit 3.9 没有可用的测试

python - 导入 flask.ext.wtf

python - 在 virtualenv 中控制 pip 版本