python - VScode 中的 Conda 环境
问题描述
我创建了两个 Anaconda 环境,比如 A 和 B,以及基本环境。我已经创建了环境 A 和 B 特定于我对它们所做的事情(不同的库)。
现在我安装了 VScode。当我打开 VScode 并首先在下部设置正确的解释器(A 或 B)并运行一些特定于 A 和 B 的 python 程序时,程序无法运行并出现错误。
D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\Do\Python\ML practice\iris\own-knn.py", line 15, in <module>
import numpy as np
File "D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "D:\Anaconda\envs\practica-mldl\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "D:\Anaconda\envs\practica-mldl\python.exe"
* The NumPy version is: "1.19.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
PS D:\Do\Python\ML practice\iris> conda activate practica-mldl
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- cmd.exe
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
但是当我通过anaconda提示打开VScode时,首先激活环境并通过键入代码并运行一些程序打开VScode,程序运行。
因此,据我了解,简单地更改 VScode 中的解释器与通过首先激活环境来打开 VScode 不同。我认为只需更改 VScode 中的解释器即可。
VScode 中是否有一个设置,我不必先激活环境来打开 VScode,这样我就可以运行特定于该环境的 python 程序?
非常感谢!
编辑 1. 添加错误
解决方案
推荐阅读
- python - 通过从列表中添加元素来创建嵌套字典
- r - 具有颜色渐变的图例/比例从某个值开始 - 定义比例中断
- mongodb - 如何从 Array 中删除嵌套的数组元素
- javascript - Angular + Rxjs 运算符 - 如果 api 未在 5 秒内完成则显示加载器显示 toastr 并隐藏加载器
- python - python列表到.txt文件,引号消失
- python - Django - Filter() 和 All() 之间更快的是什么
- azure-devops - 无法将外部用户添加到 Azure DevOps 服务器项目
- ios - 带有跟踪图像的 ARKit 场景开始跳跃
- r - R Markdown:在“元”包中执行漏斗()时找不到对象
- unit-testing - GNU Prolog 中的单元测试