setup.py 通过 conda (conda-forge opencv) 安装了 cv2 依赖项
setup.py with cv2 dependency installed via conda (conda-forge opencv)
我正在尝试收集 python 包中的代码 gnn_pylib
并将其安装到我的 conda 环境中。我的包将需要 opencv,它已通过以下方式安装在我的 conda 环境中:
conda install -c conda-forge opencv
我可以运行 cv2函数正常运行,并且我可以成功调用使用cv2函数的包中的函数:
import gnn_pylib
gnn_pylib.show()
但是当我尝试安装包时 运行ning pip install -e .
从 gnn_pylib
目录我得到以下错误:
Collecting cv2 (from gnn-pylib==0.1)
Could not find a version that satisfies the requirement cv2 (from gnn-pylib==0.1) (from versions: )
No matching distribution found for cv2 (from gnn-pylib==0.1)
有什么我想念的吗?我应该以某种方式通知 pip
但我的 conda
opencv 吗?
包具有以下结构:
gnn_pylib/
gnn_pylib/
__init__.py
show.py
setup.py
__init__.py
如下:
from .show import foo
show.py
如下:
import cv2
import numpy as np
def foo():
cv2.imshow("random", np.random.rand(10,10))
cv2.waitKey()
return
setup.py
如下:
from setuptools import setup
setup(name='gnn_pylib',
version='0.1',
description='General purpose python library',
url='http://github.com/whatever/gnn_pylib',
author='whatever',
author_email='whatever@gmail.com',
license='MIT',
packages=['gnn_pylib'],
install_requires=[
'numpy',
'cv2',
],
zip_safe=False)
与其使用 cv2
作为所需的包名称,不如使用 opencv-python
,因为这是 PyPI 提供的 OpenCV 绑定包的名称。所以你的 setup.py
文件将看起来像这样(与上面相同,但 OpenCV 绑定包要求的条目不同):
from setuptools import setup
setup(name='gnn_pylib',
version='0.1',
description='General purpose python library',
url='http://github.com/whatever/gnn_pylib',
author='whatever',
author_email='whatever@gmail.com',
license='MIT',
packages=['gnn_pylib'],
install_requires=[
'numpy',
'opencv-python',
],
zip_safe=False)
@James Adams
回答 cv2
的具体情况,替换为更兼容的 opencv-python
.
但是,如果您仍然希望从 conda
安装依赖项,请考虑制作一个 conda 包。
查看类似问题的答案:
Use 'conda install' instead of 'pip install' for setup.py packages
我还找不到详细的步骤和示例的答案。但希望它能有所帮助。
我正在尝试收集 python 包中的代码 gnn_pylib
并将其安装到我的 conda 环境中。我的包将需要 opencv,它已通过以下方式安装在我的 conda 环境中:
conda install -c conda-forge opencv
我可以运行 cv2函数正常运行,并且我可以成功调用使用cv2函数的包中的函数:
import gnn_pylib
gnn_pylib.show()
但是当我尝试安装包时 运行ning pip install -e .
从 gnn_pylib
目录我得到以下错误:
Collecting cv2 (from gnn-pylib==0.1)
Could not find a version that satisfies the requirement cv2 (from gnn-pylib==0.1) (from versions: )
No matching distribution found for cv2 (from gnn-pylib==0.1)
有什么我想念的吗?我应该以某种方式通知 pip
但我的 conda
opencv 吗?
包具有以下结构:
gnn_pylib/
gnn_pylib/
__init__.py
show.py
setup.py
__init__.py
如下:
from .show import foo
show.py
如下:
import cv2
import numpy as np
def foo():
cv2.imshow("random", np.random.rand(10,10))
cv2.waitKey()
return
setup.py
如下:
from setuptools import setup
setup(name='gnn_pylib',
version='0.1',
description='General purpose python library',
url='http://github.com/whatever/gnn_pylib',
author='whatever',
author_email='whatever@gmail.com',
license='MIT',
packages=['gnn_pylib'],
install_requires=[
'numpy',
'cv2',
],
zip_safe=False)
与其使用 cv2
作为所需的包名称,不如使用 opencv-python
,因为这是 PyPI 提供的 OpenCV 绑定包的名称。所以你的 setup.py
文件将看起来像这样(与上面相同,但 OpenCV 绑定包要求的条目不同):
from setuptools import setup
setup(name='gnn_pylib',
version='0.1',
description='General purpose python library',
url='http://github.com/whatever/gnn_pylib',
author='whatever',
author_email='whatever@gmail.com',
license='MIT',
packages=['gnn_pylib'],
install_requires=[
'numpy',
'opencv-python',
],
zip_safe=False)
@James Adams
回答 cv2
的具体情况,替换为更兼容的 opencv-python
.
但是,如果您仍然希望从 conda
安装依赖项,请考虑制作一个 conda 包。
查看类似问题的答案:
Use 'conda install' instead of 'pip install' for setup.py packages
我还找不到详细的步骤和示例的答案。但希望它能有所帮助。