我的环境
$ cat /etc/centos-release
CentOS Linux release 7.3.1611 (Core)
$ python --version
Python 3.6.3 :: Anaconda, Inc.
我创建了一个虚拟环境并使用它;设置环境变量;
$ sudo chown -R tonynb:tonynb anaconda3 # anaconda3 owns to me
$ which python
/opt/anaconda3/bin/python
$ conda create --name ve # My virtual environment
$ source activate ve
(ve)$ which python
/opt/anaconda3/envs/ve/bin/python
我开始安装软件包
(ve)$ pip install pymongo
(ve)$ pip install jupyter notebook
(ve)$ jupyter notebook
(ve)$ pip freeze
pymongo==3.5.1
jupyter==1.0.0
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.4.0
....
一切都很好。但是当我在jupyter笔记本中时,当我输入此错误时发生错误
import pymongo
ModuleNotFoundError: No module named 'pymongo'
似乎它只搜索
中的包 /opt/anaconda3/lib/python3.6/site-packages
不是/opt/anaconda3/envs/ve/lib/python3.6/site-packages
$ which pip
/opt/anaconda3/bin/pip
(ve)$ which pip
/opt/anaconda3/envs/ve/bin/pip
我误解了什么吗?或者出了什么问题?