无法在Python virtualenv中导入已安装的模块

时间:2018-09-12 12:15:41

标签: python docker pip anaconda setup.py

我已经在带有mypackage的目录中使用pip install .安装了自己的python软件包setup.py。似乎该软件包已安装,但是当我尝试导入它时,我得到了ModuleNotFoundError

请参阅以下终端会话:

(venv-docker) root@71f904d6e6ed:/../scripts# pip list | grep mypackage
mypackage (0.0.3)
(venv-docker) root@71f904d6e6ed:/../scripts# which pip
/../venv-docker/bin/pip
(venv-docker) root@71f904d6e6ed:/../scripts# which python
/../venv-docker/bin/python
(venv-docker) root@71f904d6e6ed:/../scripts# python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mypackage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mypackage'

这怎么会发生?

我该如何解决?

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为videoset是mypackage中的一个模块

from <package_name>  import <module_name>