首页 > 解决方案 > 尝试安装 chat-replay-downloader 导致“没有模块名为打字”

问题描述

我正在尝试将 chat-replay-downloader python 包安装到 ubuntu 16.04LTS 系统上。我对 Pyton 知之甚少,因此,试图通过搜索找到原因并没有帮助。

> pip install chat-replay-downloader
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named typing
delovelady@web:/home/delovelady   05/20 19:27:05
> pip install typing
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named typing

您可能还会发现了解安装了哪些 Python 模块很有用,因此这里是该列表:

> apt list --installed|grep '^python'

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

python/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
python-apt-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.1.0~beta1ubuntu0.16.04.11 all [installed,automatic]
python-minimal/xenial-updates,now 2.7.12-1~16.04 amd64 [installed,automatic]
python-pkg-resources/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python-setuptools/xenial,xenial,now 20.7.0-1 all [installed]
python2.7/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.18 amd64 [installed,automatic]
python2.7-minimal/xenial-updates,xenial-security,now 2.7.12-1ubuntu0~16.04.18 amd64 [installed,automatic]
python3/xenial,now 3.5.1-3 amd64 [installed]
python3-apt/xenial-updates,xenial-security,now 1.1.0~beta1ubuntu0.16.04.11 amd64 [installed,automatic]
python3-blinker/xenial,xenial,now 1.3.dfsg2-1build1 all [installed,automatic]
python3-cffi-backend/xenial,now 1.5.2-1ubuntu1 amd64 [installed,automatic]
python3-chardet/xenial,xenial,now 2.3.0-2 all [installed,automatic]
python3-commandnotfound/xenial-updates,xenial-updates,now 0.3ubuntu16.04.2 all [installed]
python3-configobj/xenial,xenial,now 5.0.6-2 all [installed,automatic]
python3-cryptography/xenial-updates,xenial-security,now 1.2.3-1ubuntu0.3 amd64 [installed,automatic]
python3-dbus/xenial,now 1.2.0-3 amd64 [installed,automatic]
python3-distupgrade/xenial-updates,xenial-updates,now 1:16.04.32 all [installed]
python3-gdbm/xenial,now 3.5.1-1 amd64 [installed]
python3-gi/xenial,now 3.20.0-0ubuntu1 amd64 [installed,automatic]
python3-idna/xenial,xenial,now 2.0-3 all [installed,automatic]
python3-jinja2/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2.8-1ubuntu0.1 all [installed,automatic]
python3-json-pointer/xenial,xenial,now 1.9-3 all [installed,automatic]
python3-jsonpatch/xenial,xenial,now 1.19-3 all [installed,automatic]
python3-jwt/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.3.0-1ubuntu0.1 all [installed,automatic]
python3-markupsafe/xenial,now 0.23-2build2 amd64 [installed,automatic]
python3-minimal/xenial,now 3.5.1-3 amd64 [installed]
python3-oauthlib/xenial,xenial,now 1.0.3-1 all [installed,automatic]
python3-pkg-resources/xenial,xenial,now 20.7.0-1 all [installed,automatic]
python3-pyasn1/xenial,xenial,now 0.1.9-1 all [installed,automatic]
python3-pycurl/xenial,now 7.43.0-1ubuntu1 amd64 [installed,automatic]
python3-pyinotify/xenial,xenial,now 0.9.6-0fakesync1 all [installed,automatic]
python3-requests/xenial-updates,xenial-updates,xenial-security,xenial-security,now 2.9.1-3ubuntu0.1 all [installed,automatic]
python3-serial/xenial,xenial,now 3.0.1-1 all [installed]
python3-six/xenial,xenial,now 1.10.0-3 all [installed,automatic]
python3-software-properties/xenial-updates,xenial-updates,xenial-security,xenial-security,now 0.96.20.10 all [installed,automatic]
python3-systemd/xenial,now 231-2build1 amd64 [installed,automatic]
python3-update-manager/xenial-updates,xenial-updates,now 1:16.04.17 all [installed]
python3-urllib3/xenial-updates,xenial-updates,xenial-security,xenial-security,now 1.13.1-2ubuntu0.16.04.4 all [installed,automatic]
python3-yaml/xenial,now 3.11-3build1 amd64 [installed,automatic]
python3.5/xenial-updates,xenial-security,now 3.5.2-2ubuntu0~16.04.13 amd64 [installed]
python3.5-minimal/xenial-updates,xenial-security,now 3.5.2-2ubuntu0~16.04.13 amd64 [installed]
python38/now 3.8.6-1 amd64 [installed,local]

我没有故意安装任何 Python 的东西。所有这些都必须在安装时或由于某些依赖性而被引入。

同样,我无法开始猜测这里可能出了什么问题。我只能说,在另一个(Ubuntu 20.04)系统上,我以类似方式下载了它,它似乎运行正常。

更新基于博士建议。

我按照 [https://bootstrap.pypa.io/2.7/get-pip.py][1] 降级了我的 pip 版本。这使我找到了一个更新的链接,如下所示:

> curl -O https://bootstrap.pypa.io/2.7/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   936  100   936    0     0   3742      0 --:--:-- --:--:-- --:--:--  3744

> python get-pip.py

Hi there!

The URL you are using to fetch this script has changed, and this one will no
longer work. Please use get-pip.py from the following URL instead:

    https://bootstrap.pypa.io/pip/2.7/get-pip.py

(etc)

> curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1863k  100 1863k    0     0  7935k      0 --:--:-- --:--:-- --:--:-- 7963k

> python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 19.0 MB/s
Collecting wheel
  Downloading wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, wheel
  WARNING: The scripts pip, pip2 and pip2.7 are installed in '/home/delovelady/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The script wheel is installed in '/home/delovelady/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.3.4 wheel-0.36.2

> export PATH="${PATH}:/home/delovelady/.local/bin"
> pip install chat-replay-download
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 9, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named typing

更新 2

再次感谢@phd,我已经根据他的以下建议调整了路径,现在问题有点不同了。

 pip install chat-replay-download
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement chat-replay-download (from versions: none)
ERROR: No matching distribution found for chat-replay-download

请注意,由于有关“站点包”的评论不可写,我尝试使用sudo pip install chat-replay-download进行此操作。结果是旧的错误消息。

标签: pythonpython-2.7pip

解决方案


推荐阅读