Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wanted to download Requests: HTTP for Humans module for python3. So I started with

sudo apt-get install python3-pip
sudo pip3 install requests --upgrade

There were no errors. However, when I try to import module, there are some errors:

enedil@VirtualBox:~/hacking$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 2195, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 12, in <module>
    from http.client import HTTPConnection as _HTTPConnection, HTTPException
ImportError: No module named 'http.client'; 'http' is not a package

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python3.4/dist-packages/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python3.4/dist-packages/requests/compat.py", line 7, in <module>
    from .packages import chardet
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 36, in <module>
    from .connection import (
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 14, in <module>
    from httplib import HTTPConnection as _HTTPConnection, HTTPException
ImportError: No module named 'httplib'
Error in sys.excepthook:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2195, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
    from urllib.request import urlopen
  File "/usr/lib/python3.4/urllib/request.py", line 88, in <module>
    import http.client
ImportError: No module named 'http.client'; 'http' is not a package

Original exception was:
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2195, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 12, in <module>
    from http.client import HTTPConnection as _HTTPConnection, HTTPException
ImportError: No module named 'http.client'; 'http' is not a package

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/local/lib/python3.4/dist-packages/requests/utils.py", line 25, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "/usr/local/lib/python3.4/dist-packages/requests/compat.py", line 7, in <module>
    from .packages import chardet
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/__init__.py", line 3, in <module>
    from . import urllib3
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/__init__.py", line 16, in <module>
    from .connectionpool import (
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connectionpool.py", line 36, in <module>
    from .connection import (
  File "/usr/local/lib/python3.4/dist-packages/requests/packages/urllib3/connection.py", line 14, in <module>
    from httplib import HTTPConnection as _HTTPConnection, HTTPException
ImportError: No module named 'httplib'

So, how to install requests module for python3 on Ubuntu 14.04?

share|improve this question
1  
Why not apt-get install python3-requests? –  bain Jul 29 at 10:43

1 Answer 1

up vote 3 down vote accepted

For 14.04, you just need to install python3-requests:

sudo apt-get install python3-requests
share|improve this answer
    
Now I have installed requests. But still it does not work. I'm getting exception errors: Original exception was: Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'requests' is not defined –  enedil Jul 29 at 11:02
    
Are you able to run a simple python3 -c "import requests" –  Sylvain Pineau Jul 29 at 11:04
    
Still the same exception. –  enedil Jul 29 at 11:09
    
Try to remove what you partially installed in /usr/local with sudo pip3 uninstall requests –  Sylvain Pineau Jul 29 at 11:22
1  
I simply rebooted system (was on VM so it was fast) and it works. –  enedil Jul 29 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.