我最近发现了这个问题,但我不记得以前发生过这个问题:
如果我创建了一个名为test的新环境,安装了python和未预先安装在基本环境中的包,例如netCDF
(base) $ conda create -n test
(base) $ source activate test
(test) $ conda install python
(test) $ conda install -c conda-forge netcdf4但在命令行中,它似乎仍然使用基本环境的python:
(test) $ which python
/mypath/anaconda3/bin/python因此,在python shell中,它无法导入netcdf
(test) $ python
>>> import netCDF4
ModuleNotFoundError: No module named 'netCDF4'但在我的IDE (例如jupyter notebook)中,它工作得很好。它成功地在test环境中使用了python,因为它可以顺利地导入netCDF:
[1] import netCDF4 (in jupyter, it is imported successfully)为什么会出现这种情况?为什么我在test环境下还在使用base环境下的python?
任何建议都是有帮助的。非常感谢!
发布于 2020-08-24 18:09:51
$ conda create --name test python=3.7
$ conda activate test
$ which python输出: /home/user/miniconda3/envs/test/bin/python
https://stackoverflow.com/questions/63557435
复制相似问题