简体   繁体   English

安装 python 3 后,httpie 仍然使用 python 2.7

[英]httpie still use python 2.7 when python 3 is installed

I installed httpie via command我通过命令安装了 httpie

sudo yum install httpie

python3 command is on the PATH. python3 命令在 PATH 上。 But when I run http command it still use python 2.7 which cause error.但是当我运行 http 命令时,它仍然使用导致错误的 python 2.7。

http command error http命令错误

    Traceback (most recent call last):
  File "/usr/bin/http", line 9, in <module>
    load_entry_point('httpie==0.9.4', 'console_scripts', 'http')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/site-packages/httpie/__main__.py", line 5, in <module>
    from .core import main
  File "/usr/lib/python2.7/site-packages/httpie/core.py", line 17, in <module>
    import requests
  File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in <module>
    from .exceptions import InvalidURL
  File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in <module>
    from urllib3.exceptions import HTTPError as BaseHTTPError
  File "/usr/lib/python2.7/site-packages/urllib3/__init__.py", line 10, in <module>
    from .connectionpool import (
  File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 31, in <module>
    from .connection import (
  File "/usr/lib/python2.7/site-packages/urllib3/connection.py", line 45, in <module>
    from .util.ssl_ import (
  File "/usr/lib/python2.7/site-packages/urllib3/util/__init__.py", line 5, in <module>
    from .request import make_headers
  File "/usr/lib/python2.7/site-packages/urllib3/util/request.py", line 5, in <module>
    from ..exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError

I can confirm python 3 is installed, python shell when I run python command当我运行 python 命令时,我可以确认安装了 python 3,python shell

Python 3.8.5 (default, Sep  4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Without knowing your OS and its version, it will be a guess answer :)在不知道您的操作系统及其版本的情况下,这将是一个猜测答案:)

I bet you are running an old Fedora version or CentOS?我敢打赌您运行的是旧版 Fedora 或 CentOS?

If that's the case, the HTTPie version is very old (0.9.4), and at that time it was bundled using Python 2. So when you do sudo yum install httpie it will install http and https executable as Python 2 modules.如果是这种情况,那么 HTTPie 版本非常旧 (0.9.4),当时它是使用 Python 2 捆绑的。因此,当您执行sudo yum install httpie ,它将安装httphttps可执行文件作为 Python 2 模块。

One solution that was proposed in comments is to use python3 -m pip install --upgrade httpie : it will make sure you are installing HTTPie for Python 3. And http & https executable will be available too.在评论中提出的一种解决方案是使用python3 -m pip install --upgrade httpie :它将确保您为 Python 3 安装 HTTPie。并且httphttps可执行文件也将可用。 If you do so, you must first remove the HTTPie version you installed via yum .如果这样做,您必须首先删除通过yum安装的 HTTPie 版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Mac OS X 上安装了 Python 3 但它仍然是 Python 2.7 - Installed Python 3 on Mac OS X but its still Python 2.7 Flask是为Python 2.7而非Python 3安装的 - Flask is installed for Python 2.7 and not for Python 3 安装了Python的模块仍然无法使用它 - Python installed module still can’t use it Autotools - 当Python 3可用时使用Python 2.7 - Autotools - Use Python 2.7 when Python 3 is available 已安装 Python 2.7 和 Python 3.7。 如何将 MadGraph 与 Python 2.7 一起使用? - Python 2.7 and Python 3.7 installed. How to use MadGraph with Python 2.7? Sublime文本3仍然使用python 2.7。 [我已经卸载它并安装了python 3.3] - Sublime text 3 still using python 2.7. [ I have uninstalled it and installed python 3.3 ] 安装了Python 3.7,并尝试将其更改为默认值,但是更改$ PATH并运行python --version仍显示2.7 - Installed Python 3.7 and tried changing that to the default however, changing $PATH and running python --version still shows 2.7 在 MAC OS 上安装了 Python 3.9.1 但仍然说 Python 版本是 2.7 - Installed Python 3.9.1 onto MAC OS but still says Python version is 2.7 如何在本地安装pip以与Python 2.7一起使用? - How can pip be installed locally for use with Python 2.7? 在没有安装gcc的情况下安装python 2.7 - Install python 2.7 with no gcc installed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM