I am implementing selenium and i have already included "from selenium import webdriver" but still getting this error
"ImportError: cannot import name webdriver"
Any idea how to resolve this error?
Cross check your language binding, check with older versions
Related
new in python.
I have python 2.7.
I just installed a new module (beatifulsoup) from cmd in windows 7 which is correctly installed : When I enter the python consol from the cmd I can import succesfully bs4 without error.
My problem is that I cannot import it when I am using Aptana studio. Or if I code it in sublimetext and save it as a py file, when I run it I get the error message "cannot import name beautifulsoup 4". I don't get why? Is it a problem of pydev environment on aptana? If yes how can I add modules to Aptana and sublimetext3 ?
Are you trying to import like this:
from bs4 import BeautifulSoup
If not, try it that way. Hope this helps!
(Perhaps you should add your import statement to the question so we can see if there is a problem with the statement or if the issue resides somewhere else)
I am trying to compile a python code with cx_freeze in Windows 7, python 2.7, but it keeps giving me trouble because of pyserial. I tried to import the pyserial tools module in many different ways but I keep getting compilation errors:
import serial
import serial.tools
from serial.tools import list_ports
#I also tried:
#import serial.tools.list_ports
#from serial import tools
#import serial.tools.list_ports
#from serial import tools
The error message varies between:
ImportError: No module named tools
and
ImportError: No module named tools.list_ports
Any ideas on how to solve this issue? Thanks.
I am trying to sort the following error but not getting the correct answer till now. Actually I am using Ubuntu 10.04 and I have installed netcdf-3.6.2 but even then i found this error, although I added the header like
import Scientific.IO.NetCDF
from Numeric import *
from NetCDF import *
But it does not make any impact and shows the following error:
ImportError: No module named NetCDF
If the module is Scientific.IO.NetCDF, then you need to do from Scientific.IO.NetCDF import * (and you don't need to do import Scientific.IO.NetCDF first). Also, importing everything is often a bad style, and should be avoided.
I have a Python pyd module written in C++. I also have a Python version of the module (which is much slower).
My question is, as I want the program to run on multiple OSs, can I try to import the C++ version in the program and import the slower Python version if that one fails (other OS, architecture)?
Yes, you can import some thing like this:
try:
import CppModule as Module
except ImportError:
import PurePythonModule as Module
Yes you can:
try:
import CppModule
except ImportError:
import PythonModule
Edit: This answer, while not incorrect, is not really useful. As #Best Games' answer shows, this only really useful if you import the module using a common name.
Everything works as supposed to on the Django development server. In Apache, the django app also works except when matplotlib is used. Here's the error I get:
No module named multiarray.
Exception Type: ImportError
Exception Value: No module named multiarray
Exception Location: /usr/share/pyshared/numpy/core/numerictypes.py in <module>, line 81
Python Executable: /usr/bin/python
Python Version: 2.6.4
From the python shell, both statements work: import numpy.core.multiarray and import multiarray. Any ideas?
Thanks
As I'm looking over the numpy files, I found the multiarray module, which has an extension of 'so'. My guess, is that mod_python is not reading these files.
Problem solved. Here's what I did.
First of all, before I was getting the import error:
"No module named multiarray."
I was getting an error like this:
": Failed to create /some/dir/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"
By adding the pyshared folder to the PythonPath variable, this error went away and I got the import error.
So here's how I fixed it:
Removed the pyshared folder from the PythonPath variable.
Before importing the matplotlib module, add these lines:
import os
os.environ['HOME']='/some/writable/dir'
Next, before import matplotlib.pyplot or pylab, add these lines:
import matplotlib
matplotlib.use('Agg')
# 'Agg' or whatever your backend is.
This is documented here.
That's is! It's working on python2.5 for me now. But I believe it'll work on 2.6 as well.
On Win32 I solved a similar problem (not being able to load pyd modules through ISAPI_WSGI (IIS)) by downgrading from py2.6.5 to py2.5. It seems like this might be a Python bug that has been re-introduced. See for example this discussion.