Python 包裹没有 setup.py,

Python package does not have setup.py,

我想用 pip 安装这个库:ikpy library。但是 pip 给出以下错误:

Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/tmp/pip-build-oYTjdr/ikpy/setup.py'

我从错误中了解到,pip 找不到 setup.py,因为库有 setup.cfg。我尝试升级 pip,但出现了不同的错误。

$ pip install --upgrade pip
Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-KCnfi9/pip/setup.py", line 7
        def read(rel_path: str) -> str:
                         ^
    SyntaxError: invalid syntax

我也试过 pip3:

$ pip3 install ikpy
ModuleNotFoundError: No module named 'pip._vendor.pkg_resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in <module>
    from pip.exceptions import InstallationError, CommandError, PipError
  File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 956, in subscribe
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in <lambda>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'

我该怎么办?

Python 3.7.10, python3-pip: (8.1.1-2ubuntu0.6).

注:

我用这些命令解决了,现在可以用pip3安装了:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py 
pip3 install --upgrade setuptools

(此消息是在使用 pip3 更新问题之前创建的)

您使用的 pip 命令很可能是针对 Python 2. 您可以试试 pip3 吗?

来自 ikpy 库:

Starting with IKPy v3.1, only Python 3 is supported. 
For versions before v3.1, the library can work with both versions of Python (2.7 and 3.x).

您可以在此处下载与 python 2 兼容的最新版本: https://github.com/Phylliade/ikpy/releases/tag/v3.0.1

注意:不建议使用 python 2.7,因为对 Python 2.7 版的支持将于 2020 年 1 月 1 日结束

升级你的Pip

 pip install --upgrade pip

然后安装 ikpy 现在它应该启动 运行 ;-)

pip install ikpy

现在安装并检查:Ubuntu 20.04,Pip 21.3,Python 3.8.10