python - How to solve "Error: [Win Error2] The system cannot find the file specified"
问题描述
I want to set up a python3 virtual environment in my Workspace. I have two versions of python, installed in the following paths: C:\Python\Python27\python2.exe
C:\Python\Python38\python3.exe
. I already checked on the powershell terminal that they are properly installed.
I tried the command python3 -m venv .venv
. It created a .venv
folder, but I get the following error message: "Error: [Win Error2] The system cannot find the file specified
.
My IDE is Visual Studio Code 1.39.2
Also, Python3 is added to path in the Variable environment C:\Python\Python38
I also tried to use the command py -3 -m venv .venv
, but then I get:
Python 3 not found! Installed Pythons found by C:\WINDOWS\py.exe
launchers for Windows
No Installed Pythons found
I also already executed the command Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
but nothing changed.
My settings.json file:
{ "python;pythonPath": "C:\\Python\\Python38\\python3.exe" }
My pyvenv.cfg file:
home = C:\Python\Python38
include-system-site-package = false
version = 3.8.0
解决方案
我建议在执行命令时使用 Python 3 文件夹的绝对路径,例如:
"%USERPROFILE%\AppData\Local\Programs\Python38\python.exe" -m venv .env
这解决了我的问题。
推荐阅读
- android - 如何在嵌套滚动视图中获取所有 Recycler View 项目视图位置(x,y)
- php - 使用 Key 获取 API Endpoint 值?
- android - 我们应该使用 ViewModels 在单个活动应用架构中的 2 个不同片段或包之间进行通信吗?
- ruby - 如果使用 CDN,如何获取当前 URL 的主机?
- python - Python 请求问题 - POST
- php - $_SESSION 与 $_FILES 冲突
- vue.js - Vue测试组件:无法从小吃栏中选择元素
- javascript - 复制功能有效,如何去除逗号代码?
- kotlin - Kotlin 数学与数学
- stanford-nlp - TrueCaseAnnotator overwriteText 选项