尝试安装django-visits时如何解决“错误:命令错误,退出状态1:”

时间:2020-04-27 01:37:18

标签: python django

我正在尝试安装django-visits,但是每当我运行“ pip install django-visits” 命令时,都会出现以下错误:

ERROR: Command errored out with exit status 1:
command: 'c:\users\samuel\appdata\local\programs\python\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Samuel\\AppData\\Local\\Temp\\pip-insta
ll-8t2j3cs9\\distribute\\setup.py'"'"'; __file__='"'"'C:\\Users\\Samuel\\AppData\\Local\\Temp\\pip-install-8t2j3cs9\\distribute\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__fi
le__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3c
s9\distribute\pip-egg-info'
         cwd: C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\
    Complete output (15 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\setuptools\__init__.py", line 2, in <module>
        from setuptools.extension import Extension, Library
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\setuptools\extension.py", line 5, in <module>
        from setuptools.dist import _get_unpatched
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\setuptools\dist.py", line 7, in <module>
        from setuptools.command.install import install
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\setuptools\command\__init__.py", line 8, in <module>
        from setuptools.command import install_scripts
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\setuptools\command\install_scripts.py", line 3, in <module>
        from pkg_resources import Distribution, PathMetadata, ensure_directory
      File "C:\Users\Samuel\AppData\Local\Temp\pip-install-8t2j3cs9\distribute\pkg_resources.py", line 1518, in <module>
        register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
    AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```


How can I fix it?

1 个答案:

答案 0 :(得分:1)

只需尝试pip3 install django-visits,看看它是否有效。如果没有,请按照以下解决方案进行操作。

我认为这是因为python3.7pip是从不同来源安装的。 我建议使用python的内置工具来安装pip,即

python3 -m ensurepip --upgrade

这应该安装pip3pip3.x,其中python3.x中的x。