我在Python项目中使用TensorFlow object detection API。为了在PyCharm中运行代码,我将TensorFlow git存储库的models/research目录的位置作为"Content Root“。当我在命令行运行代码时,我在PYTHONPATH中包含了这个目录位置。这很简单,但是如果可以将TensorFlow object-detection模块与我的项目的package的其他依赖项一起安装到环境中,我希望消除用户处理这一问题的需要。
我已经尝试将以下内容添加到我的requirements.txt中,但无济于事(即pip install requirements.txt挂起):
-e git+https://github.com/tensorflow/models.git#egg=research我还尝试在setup.py中读取requirements.txt中的所有行以获取依赖项链接,但在运行python setup.py install时,使用这种方法也不起作用。
在Object Detection API Demo中,先是存储库的克隆,然后是通过
cd models/research
pip install .这样的事情可以通过我的项目的requirements.txt中的适当条目和/或setup.py中的一些代码来完成吗?
我的目标是,如果用户还没有“手动”将TensorFlow对象检测API安装到他们的Python环境中,那么当我的代码调用import object_detection等时,不会得到ModuleNotFoundError。
发布于 2020-01-05 11:48:19
egg=...参数仅用于告诉pip模块的名称。要从存储库的research子目录安装,请附加另一个参数:
## requirements.txt
-e git+https://github.com/tensorflow/models.git#egg=research&subdirectory=research在命令行中:
$ pip install -e git+https://github.com/tensorflow/models.git#egg=research\&subdirectory=research(注意转义的&,因为它在大多数shell中是一个特殊字符)。
https://stackoverflow.com/questions/59596694
复制相似问题