Pregunta

I've used these modules before, even in a Python script inside a folder where I have other working scripts. Here's my imports:

import os
import sys    
import urllib.request as urllib, simplejson as json, requests
import subprocess
import Popen, PIPE
import time

I get this in my console:

Traceback (most recent call last):
  File "party.py", line 4, in <module>
    import urllib.request as urllib, simplejson as json, requests
ImportError: No module named request

How come? I've tried

sudo pip install request

..but with no luck. What is causing this?

¿Fue útil?

Solución

what python version are you using? urllib.request seems to be python3

v2.7

>>> import urllib.request
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named request
>>> 

v3.3

>>> import urllib.request
>>> urllib.request
<module 'urllib.request' from '/usr/lib/python3.3/urllib/request.py'>
>>> 
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top