[英]Pipenv installing a local package but getting "ModuleNotFoundError: No module named"
I have a local project which I am developing and I want to install it into my pipenv so that I can try running some scripts that use the code I have developed.我有一个正在开发的本地项目,我想将它安装到我的 pipenv 中,以便我可以尝试运行一些使用我开发的代码的脚本。
I created a very basic setup.py located in the root of the project ( mypackage/setup.py
):我创建了一个非常基本的 setup.py 位于项目的根目录(
mypackage/setup.py
):
from setuptools import find_packages, setup
setup(
name="mypackage",
version="0.1",
packages=find_packages(),
)
And have also added __init__.py
files (although they are all empty, but that should be fine) into all of the desired directories within the project.并且还将
__init__.py
文件(虽然它们都是空的,但应该没问题)添加到项目中所有所需的目录中。
Then when I run pipenv install /Users/me/path/to/mypackage
it tells me that it is installing 'mypackage', and then it even adds it to the pipfile.然后当我运行
pipenv install /Users/me/path/to/mypackage
它告诉我它正在安装“mypackage”,然后它甚至将它添加到 pipfile 中。
But then when I run the venv pipenv shell
and try importing the package python -c 'import mypackage'
(also tried using python3 but same result), I get the error: ModuleNotFoundError: No module named 'mypackage'
. But then when I run the venv
pipenv shell
and try importing the package python -c 'import mypackage'
(also tried using python3 but same result), I get the error: ModuleNotFoundError: No module named 'mypackage'
.
I also tried to remove the venv pipenv --rm
and re-install it pipenv install
, but the same result.我还尝试删除 venv
pipenv --rm
并重新安装它pipenv install
,但结果相同。 So at this point I'm a bit stuck on what I should do.所以在这一点上,我有点坚持我应该做什么。
Not sure but try to see where your virtual environment is and list of packages inside it.不确定,但请尝试查看您的虚拟环境在哪里以及其中的软件包列表。
pipenv --where
pipenv --venv
pipenv graph
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.