python -c 'import pyscopg2'
这很好。
现在我创建了一个virtualenv
virtualenv venv
并激活它
source venv/bin/activate
并运行以下
python -c 'import pyscopg2'
但它给出错误'ImportError:没有名为pyscopg2的模块'
答案 0 :(得分:4)
您应该使用--system-site-packages
选项创建虚拟环境以访问系统包。
根据virtualenv --help
:
--no-site-packages Don't give access to the global site-packages dir to
the virtual environment (default)
--system-site-packages
Give access to the global site-packages dir to the
virtual environment