[英]Pip install and run git repo
I'm trying to pip install a separate git repo into my python project. 我试图将一个单独的git repo安装到我的python项目中。 Pip install seems to work when I run
pip install git+https://github.com/XxdpavelxX/myapp
. 当我运行
pip install git+https://github.com/XxdpavelxX/myapp
时,Pip安装似乎可以正常工作。 However when I then run my code I get the following error. 但是,当我随后运行代码时,出现以下错误。
Here's my app: https://github.com/XxdpavelxX/myapp 这是我的应用程序: https : //github.com/XxdpavelxX/myapp
ModuleNotFoundError: No module named 'myapp'
ERROR: could not load /Users/myUser/stuff/callerFile.py
Here's the callerFile.py
(in a separate git repo): 这是
callerFile.py
(在单独的git repo中):
from myapp import test
print test.random_print()
I suspect that this is pip install
related. 我怀疑这与
pip install
有关。 When I run pip install git+https://github.com/XxdpavelxX/myapp
it seems to pass, however inside of my python venv/lib/python3.7/site-packages
I only see myapp-1.0py3.7.eggs-info
instead of the actual package. 当我运行
pip install git+https://github.com/XxdpavelxX/myapp
,似乎通过了,但是在我的python venv/lib/python3.7/site-packages
我只看到了myapp-1.0py3.7.eggs-info
而不是实际的软件包。 Anyone knowing what I'm doing wrong? 有人知道我在做什么错吗? Do I need to add my library to pypi for this to work?
我需要将我的库添加到pypi才能正常工作吗?
Edit: Added the actual url to github repo I'm testing. 编辑:实际的URL添加到我正在测试的github回购。
Create a folder called myapp and move the __init__.py and test.py files to that folder. 创建一个名为myapp的文件夹,并将__init__.py和test.py文件移动到该文件夹。
Add the following line to your setup.py (I added after url), 将以下行添加到您的setup.py(我在url之后添加),
packages=['myapp'],
Now installation will be successful and you can import your package. 现在安装将成功,您可以导入软件包。
You don't need to post your code to pypi. 您无需将代码发布到pypi。 I suggest you to use tag
#egg
to set package name. 我建议您使用标签
#egg
设置软件包名称。 So the pip status would be like 所以点子状态就像
pip install git+https://github.com/myGitUser/myLibrary#egg=myLibrary
Your package has neither py_modules
nor packages
hence it doesn't install anything importable when installed. 您的软件包既没有
py_modules
也没有packages
因此在安装时不会安装任何可导入的内容。
My advice is to rename your __init__.py
to myapp.py
and add this to setup.py
: 我的建议是将
__init__.py
重命名为myapp.py
并将其添加到setup.py
:
setup(
…
py_modules=['myapp'],
…
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.