VS Code Python 交互式窗口找不到 Conda Env [英] VS Code Python Interactive Window Cannot find Conda Env
问题描述
每次我尝试在 Python 交互式窗口中执行我的 Python 代码时,我都会收到以下错误...
Everytime I try to execute my python code to the Python Interactive Window I get the below error...
Executing code failed : Error: Activating Python 3.7.3 64-bit ('base': conda) to run Jupyter failed with Error:
Command failed: "H:/My Documents/Continuum/anaconda3/Scripts/activate" && conda activate base &&
echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python
c:/Users/paul.victor/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/printEnvVariables.py python:
can't open file 'H:\My': [Errno 2] No such file or directory .
我有一种感觉,我应该尝试将安装在 C 驱动器中的 vscode/python 扩展重新映射到我的 anaconda 的保存位置,即 H 驱动器,但我不知道如何在vs 代码设置.任何帮助将不胜感激.
I have a feeling I'm supposed to try to remap my vscode/python extension that is installed in the C drive to where my anaconda is saved which is the H drive, but I'm not sure how to do that in the vs code settings. Any help would be greatly appreciated.
跟进原创
user8408080 是正确的,删除空间确实有帮助.我还将anaconda环境的路径修改为我公司的驱动器命名法,
user8408080 was correct that removing the space did help. I also modified the path to the anaconda environment to my companies drive nomenclature,
而不是 H:它使用了类似 \\company\user...
instead of H: it used something like \\company\user...
现在我修复了它踢出另一个错误,说即使路径正确,系统也找不到指定的路径.
Now that I fixed that it's kicking out another error saying the system cannot find the path specified even though the path is correct.
Executing code failed : Error: Activating Python 3.7.3 64-bit ('base': conda) to run
Jupyter failed with Error: Command failed:\\apachecorp.com\files\SanAntonio\Home\Paul.Victor\Documents\Continuum\anaconda3\Scripts\activate base &&
echo 'e8b39361-0157-4923-80e1-22d70d46dee6' &&
python c:/Users/paul.victor/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/printEnvVariables.py The system cannot find the path specified. .
推荐答案
看起来像你在 PATH
中的 Anaconda
和 Python Path
在 >VSCode
指向不同的地方.
Looks like your Anaconda
in PATH
and Python Path
in VSCode
are pointing in different places.
首先,在系统变量下检查您的 Anaconda 是否根据安装位置映射到 PATH
.
First, check under system variables that your Anaconda is mapped to PATH
based off where it is installed.
1-点击开始菜单Windows标志,输入路径"点击编辑系统环境标签"
1- Click Start Menu Windows logo, type "path" click on "edit the system environment labels"
2- 在用户变量的PATH
下,如果VSCode
安装正确,您将看到bin
文件的位置.如果 PATH
变量不存在,请添加它.我的看起来像 C:\Users\hSin\AppData\Local\Programs\Microsoft VS Code\bin
2- Under PATH
for User Variables, if VSCode
installed correctly to it, you will see the location of the bin
file. Add to the PATH
variable if it is not there. Mine looked like C:\Users\hSin\AppData\Local\Programs\Microsoft VS Code\bin
3 - 在系统变量的 PATH
下,如果 Anaconda
安装正确,您将看到相关的路径.有多个文件/目录应该是这里的一部分.在添加之前验证是否存在,因为其中一些特定于 Anaconda 的安装时间和您选择的设置.
3 - Under PATH
for System Variables, if Anaconda
installed correctly to it, you will see the associated paths. There are multiple files/directories that should be a part here. Verify existence before adding as some of these are specific to when Anaconda installed and what settings you chose.
C:\ProgramData\Anaconda3
;C:\ProgramData\Anaconda3\Library\mingw-w64
;C:\ProgramData\Anaconda3\Library\usr\bin
;C:\ProgramData\Anaconda3\Library\bin
;C:\ProgramData\Anaconda3\Scripts
4 - 确认 Anaconda 的所有 Path
设置后,您应该能够从终端调用 python
,而不管终端是否在目录中.如果没有,您的 VSCode
没有映射正确的解释器.转到 VSCode ->文件 ->首选项 ->Settings
然后按如下方式搜索,找到Python:Python Path
设置.它应该映射到您的 Anaconda
的根安装.标准是 C:\ProgramData\Anaconda3
4 - Once all Path
setups of Anaconda are confirmed, you should be able to call python
from the terminal regardless of directory terminal is in. If not, your VSCode
doesn't have the correct interpreter mapped. Go to VSCode -> File -> Preferences -> Settings
and then search as below to find the Python:Python Path
setting. It should map to the root installation of your Anaconda
. Standard is C:\ProgramData\Anaconda3
5 - 如果仍然无法正常工作,则您的安装出现故障,需要重新安装这两个应用程序.首先安装 Anaconda
,确保勾选添加到 PATH
的框,这在基本安装中不是默认勾选的.然后安装VSCode,并设置为默认文本编辑器.Anaconda
扩展包应该按照推荐的方式出现,如果在 Anaconda 之后安装,它将把两个软件无缝连接在一起.
5 - If still not working, your installations went to haywire and will require a reinstall of both applications. Install Anaconda
first, make sure to check off the box to add to PATH
, this is not default checked in the base installation. Then install VSCode, and set as default text editor. The Anaconda
extension pack should come up as recommended, which will tie the two softwares together seamlessly if installed after Anaconda.
这篇关于VS Code Python 交互式窗口找不到 Conda Env的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!