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?
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'>
>>>
Related
Traceback (most recent call last):
File "d:/project.py", line 2, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
Guys any idea why i get this error.
Ive installed bs4 with cmd and pip
Where do i have to install the module i am really confused
Some of them work and some of them dont
For example, bs4 doesnt but tkinter does
Can not import pandas_datareader package. Python told me that No module named 'pandas_datareader'
installed the pandas_datareader via pycharm.
import pandas.datareader as web
Traceback (most recent call last):
File "<ipython-input-4-0106485ab891>", line 1, in <module>
import pandas.datareader as web
ImportError: No module named 'pandas.datareader'
for p in sys.path:
print(p)
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\spyder\utils\site
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\python35.zip
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\DLLs
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib
C:\Users\ilike\AppData\Local\Continuum\Anaconda3
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\Sphinx-1.3.5-py3.5.egg
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\win32
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\win32\lib
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\Pythonwin
C:\Users\ilike\AppData\Local\Continuum\Anaconda3\lib\site-packages\IPython\extensions
C:\Users\ilike\.ipython
What about import pandas_datareader as web ?
I have next python 2.7 (debian) code
import sys
import random
from bs4 import BeautifulSoup
from YandexDiskException import YandexDiskException
from YandexDiskRestClient import YandexDiskRestClient
I try run, but get this message
root#vps-1074211:/tmp/beautifulsoup4-4.4.0# python /var/vah13/untitled/grep.py
Traceback (most recent call last):
File "/var/vah13/untitled/grep.py", line 5, in <module>
from bs4 import BeautifulSoup
ImportError: No module named bs4
how fix it?
I installed
pip install beautifulsoup4
apt-get install python-bs4
An application can't import the "urllib" module from the package "six". But I can import it from a test script in the same environment. Can't figure out why.
❯ nova
Traceback (most recent call last):
File "/usr/bin/nova", line 6, in <module>
from novaclient.shell import main
File "/usr/lib/python2.7/site-packages/novaclient/shell.py", line 45, in <module>
from novaclient import client
File "/usr/lib/python2.7/site-packages/novaclient/client.py", line 34, in <module>
from six.moves.urllib import parse
ImportError: No module named urllib
But if I run a simple test script, it's just fine:
#!/usr/bin/python2
from six.moves.urllib import parse
foo = parse.urlsplit("http://foo.net/florp/blorp?blap=blork")
print foo
Here's the output:
❯ ./test.py
SplitResult(scheme='http', netloc='foo.net', path='/florp/blorp', query='blap=blork', fragment='')
Tried setting my PYTHONPATH explicitly, tried it under virtualenv... nothing..
Any ideas? (Sorry I'm not a Python programmer, so it may be something obvious).
I have installed tornado and following works fine, I am able to run hello,world app
python -c "import tornado"
but following results in error
python -c ""from tornado.netutil import TCPServer"
Import error
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: cannot import name TCPServer
full code : I am trying to run this https://gist.github.com/phuslu/1231481
You made the wrong imports from the wrong package, try the following:
import sys, os, re
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.tcpserver import TCPServer
as your imports. I've tried and tested it.