在 Windows 10 上,我正在运行 VS Code 1.48.2 和 Python 3,它们都安装在拇指驱动器上。我添加了一个带有和的F:\Programs\VS Code\data
文件夹。我的项目目录是,它有一个 Pipfile。我的项目目录有一个文件,因此将安装到本地. 我还需要什么才能让这个环境正常工作?谢谢!user-data
extensions
F:\MyProject
.env
.venv\
pipenv
.venv\
.env
文件:
PYTHONPATH="F:\\Python\\Python38\\python.exe"
PYTHONHOME="F:\\MyProject\\.venv\\Scripts"
PIPENV_VENV_IN_PROJECT=True
F:\MyProject\.vscode\settings.json
文件:
{
"python.pythonPath": "f:\\MyProject\\.venv\\Scripts\\python.exe"
}
虽然,当我使用时Preferences: Open Settings
,它打开了我的F:\Programs\VS Code\data\user-data\settings.json
文件,尽管路径看起来正确(对我来说):
{
"editor.suggestSelection": "first",
"vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
"python.languageServer": "Microsoft",
"python.pythonPath": "${workspacefolder}/.venv/Scripts/python.exe",
"python.venvPath": "${workspacefolder}/.venv",
"python.venvFolders": [
".venv",
"${workspacefolder}/.venv"
]
}
使用以下步骤进行设置:
ps > cd F:\MyProject
ps > F:\Programs\VS Code\code.exe .
[In vscode integrated terminal]
PS F:\MyProject> py -m venv --system-site-packages .venv
PS F:\MyProject> pipenv shell
Loading .env environment variables…
Warning: Your Pipfile requires python_version 3.8, but you are using unknown (F:\M\.venv\S\python.exe).
$ pipenv --rm and rebuilding the virtual environment may resolve the issue.
$ pipenv check will surely fail.
Launching subshell in virtual environment…
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
PS F:\MyProject> ls .\.venv\Scripts\python.exe
Directory: F:\MyProject\.venv\Scripts
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 9/6/20 3:04 PM 532040 python.exe
PS F:\MyProject> python where
Python path configuration:
PYTHONHOME = 'F:\MyProject\.venv\Scripts'
PYTHONPATH = 'F:\Python\Python38\python.exe'
program name = 'F:\Python\Python38\python.exe'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'F:\\Python\\Python38\\python.exe'
sys.base_prefix = 'F:\\MyProject\\.venv\\Scripts'
sys.base_exec_prefix = 'F:\\MyProject\\.venv\\Scripts'
sys.executable = 'F:\\MyProject\\.venv\\Scripts\\python.exe'
sys.prefix = 'F:\\MyProject\\.venv\\Scripts'
sys.exec_prefix = 'F:\\MyProject\\.venv\\Scripts'
sys.path = [
'F:\\Python\\Python38\\python.exe',
'F:\\Python\\Python38\\python38.zip',
'F:\\MyProject\\.venv\\Scripts\\DLLs',
'F:\\MyProject\\.venv\\Scripts\\lib',
'F:\\Python\\Python38',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x000020d4 (most recent call first):
<no Python frame>
PS F:\MyProject>