ModuleNotFoundError:在 cython 安装后安装 pycocotools 期间没有名为“Cython”的模块

Chr*_*ERE 5 python pip python-3.x pycocotools

我尝试在 python 3.6.9 环境中安装 pycocotools 时遇到问题。

\n\n

我正在 Windows 10 上运行 ubuntu 18.04。我已经创建了一个环境并激活了它。我想安装软件包并使用:

\n\n
pip install <package> --user\n
Run Code Online (Sandbox Code Playgroud)\n\n

当我安装 cython 时,它工作正常,但是当我安装 pycocotools 时:

\n\n
pip install pycocotools --user\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的错误如下:

\n\n
Downloading https://files.pythonhosted.org/packages/96/84/9a07b1095fd8555ba3f3d519517c8743c2554a245f9476e5e39869f948d2/pycocotools-2.0.0.tar.gz (1.5MB)\n100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 1.5MB 1.9MB/s\nComplete output from command python setup.py egg_info:\nTraceback (most recent call last):\n  File "<string>", line 1, in <module>\n  File "/tmp/pip-build-mut7_bkf/pycocotools/setup.py", line 2, in <module>\n    from Cython.Build import cythonize\nModuleNotFoundError: No module named \'Cython\'\n\n----------------------------------------\nCommand "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mut7_bkf/pycocotools/\n
Run Code Online (Sandbox Code Playgroud)\n\n

我不明白这个错误,因为之前安装了 cython 并且在安装过程中没有出现错误消息。

\n\n

更新1

\n\n

当我使用时问题仍然存在

\n\n
python3 -m pip install \n
Run Code Online (Sandbox Code Playgroud)\n\n

但是,我有一些有趣的事情。在活跃环境中:

\n\n
@ : python3 -m pip --version\n@ : pip 9.0.1 from /env/lib/python3.6/site-packages (python 3.6)\n\n@ : python3 -m pip install --upgrade pip --user\n/env/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py:860: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\nCollecting pip\n/env/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py:860: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\n/env/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/connectionpool.py:860: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings\nDownloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)\n100% |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 1.4MB 1.6MB/s\nInstalling collected packages: pip\nSuccessfully installed pip-20.0.2\n\n@ : python3 -m pip --version\n@ : pip 9.0.1 from /env/lib/python3.6/site-packages (python 3.6)\n
Run Code Online (Sandbox Code Playgroud)\n\n

因此,该包已正确下载并安装,但当我调用它时没有任何变化。我怀疑存在路径差异,但不知道如何解决。

\n\n

有人能帮我吗 ?

\n\n

最好的,

\n\n

克里斯

\n

Kal*_*ana 3

正确的安装应该是这样的。

pip3 install Cython

pip3 install pycocotools
Run Code Online (Sandbox Code Playgroud)

如果你使用conda环境

conda install -c anaconda cython

conda install -c conda-forge pycocotools
conda install -c conda-forge/label/gcc7 pycocotools     #choose one of these three
conda install -c conda-forge/label/cf201901 pycocotools
Run Code Online (Sandbox Code Playgroud)

更新

如果上述语句不起作用,则意味着您正在使用多个 python 版本。在安装任何类似这样的包时,请指定您的 python 版本。

python3.6 -m pip install cython
Run Code Online (Sandbox Code Playgroud)

如果执行这些步骤后出现任何错误,请将该错误日志添加到您的问题中