首页 > 解决方案 > macOS Conda 环境在 VSCode 中激活但未使用正确版本的 Python 或未找到已安装的包

问题描述

这是我的系统终端的输出,我用于环境的python版本是3.8.11。

(base) user@MacBook-Pro ~ % conda activate EC
(EC) user@MacBook-Pro ~ % python
Python 3.8.11 (default, Aug  6 2021, 08:56:27) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

但是如果我在 VSCode 中选择我的 EC 环境作为 python 解释器,python 的版本是不同的,我的包不存在。

source /Users/user/opt/anaconda3/bin/activate
(base) user@MacBook-Pro Assignment1 % source /Users/user/opt/anaconda3/bin/activate
(base) user@MacBook-Pro Assignment1 % conda activate EC
(EC) user@MacBook-Pro Assignment1 % python 

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Python 2.7.16 (default, Jun 18 2021, 03:23:53) 
[GCC Apple LLVM 12.0.5 (clang-1205.0.19.59.6) [+internal-os, ptrauth-isa=deploy on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

在 VSCode 中使用python3也会加载我无法使用的 3.9。有任何想法吗?

标签: pythonmacosvisual-studio-codeconda

解决方案


推荐阅读