[英]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
,它将安装http
和https
可执行文件作为 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。并且http
和https
可执行文件也将可用。 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.