• Lindenis V536学习记录


    (1)编译出错问题:

    subprocess.CalledProcessError: Command 'XXX' returned non-zero exit status 1.

    转载自:https://blog.csdn.net/u012114438/article/details/83578113

    ubuntu系统下,系统默认python2.7和python3.5,但需要使用更高的python版本的pip3时可能遇到的错误

    问题一:

    Traceback (most recent call last):
      File "/usr/bin/pip3", line 9, in <module>
        from pip import main
    ImportError: cannot import name 'main'

    解决办法:

    sudo vim /usr/bin/pip3

    修改:

    from pip import main
    if __name__ == '__main__':
        sys.exit(main())

    为:

    from pip import __main__
    if __name__ == '__main__':
        sys.exit(__main__._main())

    注意:单下划线和双下划线

    问题二:

    使用pip3安装任何模块时的类似报错:

    Traceback (most recent call last):
      File "/usr/bin/pip3", line 11, in <module>
        sys.exit(__main__._main())
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/__init__.py", line 246, in main
        return command.main(cmd_args)
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 264, in main
        timeout=min(5, options.timeout)) as session:
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/basecommand.py", line 81, in _build_session
        insecure_hosts=options.trusted_hosts,
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 338, in __init__
        self.headers["User-Agent"] = user_agent()
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_internal/download.py", line 101, in user_agent
        zip(["name", "version", "id"], distro.linux_distribution()),
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 120, in linux_distribution
        return _distro.linux_distribution(full_distribution_name)
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 634, in linux_distribution
        self.version(),
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 688, in version
        self.lsb_release_attr('release'),
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 836, in lsb_release_attr
        return self._lsb_release_info.get(attribute, '')
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 522, in __get__
        ret = obj.__dict__[self._fname] = self._f(obj)
      File "/usr/bin/python3.6/lib/python3.6/site-packages/pip/_vendor/distro.py", line 933, in _lsb_release_info
        stdout = subprocess.check_output(cmd, stderr=devnull)
      File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 336, in check_output
        **kwargs).stdout
      File "/usr/bin/python3.6/lib/python3.6/subprocess.py", line 418, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 1.

    解决办法:

    sudo vim /usr/bin/lsb_release

    修改第一行,指明python的版本号,若安装的是python3.6则修改:

    #!/usr/bin/python3

    为:

    #!/usr/bin/python3.6

  • 相关阅读:
    《我是一只IT小小鸟》
    实现对字符串的反转输出与句子的反转输出
    7.13学习记录
    CentOS 7 不能连接网路的解决方法
    Xshell连接linux服务器不成功的乌龙问题
    Python基础(二)数据类型
    Python基础(一)
    UML精粹3
    UML精粹2
    UML精粹1
  • 原文地址:https://www.cnblogs.com/olivertian/p/16095295.html
Copyright © 2020-2023  润新知