Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need help installing requests for python 3

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.

I got pip installed.

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

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. Did I get the python 2 version of "requests" somehow?
  2. When I run "python" I get version 2.6.6. I have to explicitly run "python3.2". Do I need to do something to get 3.2 to be my default python install?
like image 899
Debby Mendez Avatar asked Dec 26 '22 19:12

Debby Mendez


1 Answers

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.

like image 110
Lennart Regebro Avatar answered Jan 04 '23 03:01

Lennart Regebro