需要帮助安装 python 3 的请求 [英] Need help installing requests for python 3

查看:22
本文介绍了需要帮助安装 python 3 的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 FreeBSD 上为 python 3 安装请求"模块.我使用的是 python 3.2,但我的机器上也安装了 python 2.6.

I'm trying to get the "requests" module installed for python 3 on FreeBSD. I'm using python 3.2, but I also have python 2.6 installed on the machine.

我安装了 pip.

pip --version 
pip 1.1 from /usr/local/lib/python3.2/site-packages (python 3.2)

我跑了pip 安装请求

I ran pip install requests

我收到了一堆语法错误,开头是:

I got a bunch of syntax errors, starting with:

  File "/usr/local/lib/python3.2/site-packages/requests/packages/chardet/chardistribution.py", line 48
    self._mDone = constants.False # If this flag is set to constants.True, detection is done and conclusion has been made
                                ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.2/site-packages/requests/packages/chardet/charsetgroupprober.py", line 44
    prober.active = constants.True
                                 ^
SyntaxError: invalid syntax

  File "/usr/local/lib/python3.2/site-packages/requests/packages/chardet/constants.py", line 46
    False = __builtin__.False

  1. 我是否以某种方式获得了请求"的 python 2 版本?
  2. 当我运行python"时,我得到了 2.6.6 版.我必须明确运行python3.2".我需要做些什么才能让 3.2 成为我的默认 python 安装吗?

推荐答案

出于某种原因,Requests 包含许多其他包,例如 oauthlib 和 chardet.但不仅仅是依赖于它们,所以它们会在您安装请求时由 pip 安装,请求的 setup.py 会尝试安装包含的包.由于某种原因,这在 Python 3 下失败.

Requests for some reason includes a lot of other packages, like oauthlib and chardet. But instead of just depending on them, so they get installed by pip when you install requests, the setup.py of requests are trying to install the packages as they are included. This fails under Python 3 for some reason.

但是,无论如何,请求模块本身似乎都已正确安装.因此,您需要做的就是也做

However, the requests module itself seems to get installed properly anyway. Therefore all you should need to do is to also do

pip install chardet2 urllib3

安装缺少的库.还报告包含第三方库作为请求中的错误.这不是怎么做的.

to install the missing libraries. Also report the inclusion of third-party libraries as a bug in requests. That's not how to do it.

这篇关于需要帮助安装 python 3 的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆