[英]installing and building multiple packages from source with pip
I want to create a Python package.我想创建一个 Python package。 To make this work, the user needs to install multiple python packages.为此,用户需要安装多个 python 包。 I also need the user to install a package that is currently only supported for installing straight from the source (ie pip install -e.
).我还需要用户安装一个 package,目前仅支持直接从源安装(即pip install -e.
)。 How do I create my own source package, which depends on another source package in a clean way?如何以干净的方式创建我自己的源 package,它依赖于另一个源 package? In my opinion, it would be best if the user can just run python setup.py
once;在我看来,用户最好只运行一次python setup.py
; which installs my package and all the requirements in requirements.txt
as well as the other package straight from the source.它直接从源头安装我的 package 和 requirements.txt 中的所有requirements.txt
以及其他 package。
I added a setup.py
file with the following content:我添加了一个setup.py
文件,内容如下:
setuptools.setup(
dependency_links=["git+https://github.com/facebookresearch/pytorch-dp.git#egg=pytorch-dp"],
packages=setuptools.find_packages(),
python_requires=">=3.6",
)
When I run the setup file I get:当我运行安装文件时,我得到:
Moving pytorch_dp-0.1-py3.6.egg to /usr/local/lib/python3.6/dist-packages
Adding pytorch-dp 0.1 to easy-install.pth file
but then if I try to import the package torchdp
:但是如果我尝试导入 package torchdp
:
import torchdp
I get the error: ModuleNotFoundError: No module named 'torchdp'
我收到错误: ModuleNotFoundError: No module named 'torchdp'
I'm using a Google Colab Notebook for GPU support.*我正在使用 Google Colab Notebook 来支持 GPU。*
Turned out I had to restart google colab, and then it worked.原来我不得不重新启动google colab,然后它就起作用了。 Yikes.哎呀。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.