首页 > 解决方案 > 安装 python 模块时出错

问题描述

PS C:\Users\user> pip install getotp
Collecting getotp
  Using cached getotp-0.0.3.tar.gz (3.4 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_f69bcd40d10d4267bbd1b13984d749e6\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_f69bcd40d10d4267bbd1b13984d749e6\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-pip-egg-info-umisjc6r'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_f69bcd40d10d4267bbd1b13984d749e6\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_f69bcd40d10d4267bbd1b13984d749e6\setup.py", line 6, in <module>
        execfile('getotp/version.py')
    NameError: name 'execfile' is not defined
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/a2/dc/6d3cea111d7f77ee7bc222928c176b7d44d9478685e0d1496656be7259d6/getotp-0.0.3.tar.gz#sha256=acf785f72fafb431997f52c67c07645ca78d1c1e464fcc95a313b0649cf7ecd4 (from https://pypi.org/simple/getotp/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached getotp-0.0.2.tar.gz (3.4 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_3e06d6eb791c4df9a1f09d94a9717ef7\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_3e06d6eb791c4df9a1f09d94a9717ef7\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-pip-egg-info-q1vmndlz'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_3e06d6eb791c4df9a1f09d94a9717ef7\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_3e06d6eb791c4df9a1f09d94a9717ef7\setup.py", line 6, in <module>
        execfile('getotp/version.py')
    NameError: name 'execfile' is not defined
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/fa/3d/43c5ad39ce25cfcbeb7bc41537c59c02ec8a06c10cd3592ef386038e23cb/getotp-0.0.2.tar.gz#sha256=5490fa2a61807d67b0010f0c9e2657a7866e8b026a7576101e5a3c5367a5a80a (from https://pypi.org/simple/getotp/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached getotp-0.0.1.tar.gz (3.2 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\appdata\local\programs\python\python39\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_e7a9683866eb4524b60b3692308caf48\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-nrr48slj\\getotp_e7a9683866eb4524b60b3692308caf48\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-pip-egg-info-9dl6hatg'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_e7a9683866eb4524b60b3692308caf48\
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-nrr48slj\getotp_e7a9683866eb4524b60b3692308caf48\setup.py", line 6, in <module>
        execfile('getotp/version.py')
    NameError: name 'execfile' is not defined
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/cd/0e/41efe822de7656c0f8874276e9e06a42e7b941b8029a7678f9cb71cbc03b/getotp-0.0.1.tar.gz#sha256=8199e2d6f3198ce14ee5d9af39f9e4bc581c9b67fb3bad4fb412773095531883 (from https://pypi.org/simple/getotp/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement getotp (from versions: 0.0.1, 0.0.2, 0.0.3)
ERROR: No matching distribution found for getotp

安装软件包时出现此错误

标签: pythonmodulepippython-module

解决方案


该软件包来自 2014 年,是为 python2 编写的。幸运的是,代码不是很长。您可以从pypi下载 .tar.gz或克隆 github [repo]( https://github.com/gmjosack/getotp]。然后手动检查代码(或2to3在每个 .py 文件上使用)并制作python3兼容并运行

python setup.py install

当你完成时。


推荐阅读