I have this written down in my code but this keeps happening and I'm unsure what to do. I followed this video but don't know where to go as I followed the steps
https://www.youtube.com/watch?v=7R5n0sNSza8
from selenium import webdriver
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
from selenium import webdriver
ModuleNotFoundError: No module named 'selenium'
Related
I'm trying the solution for this issue here: Access and handle chrome extension popup using selenium webdriver
I'm getting an error when trying to import pyrobot and could not find any solution as to why I'm seeing this import error.
Traceback (most recent call last):
File "jungle.py", line 11, in <module>
from pyrobot import Robot
ImportError: cannot import name Robot
Chads-MacBook-Pro:amazon chad$ python jungle.py
Traceback (most recent call last):
File "jungle.py", line 11, in <module>
from pyrobot import Robot
File "/Users/chad/anaconda2/lib/python2.7/site-packages/pyrobot/__init__.py", line 3, in <module>
from .browser import RoboBrowser
File "/Users/chad/anaconda2/lib/python2.7/site-packages/pyrobot/browser.py", line 12, in <module>
from .forms.form import Form
ImportError: No module named forms.form
I am doing some beginner Selenium to automate a task in the browser. I have installed Selenium using pip install selenium and I know it installed successfully because I saw the following message: Successfully installed selenium-3.9.0.
Okay so that's clear Selenium is up and working.
I want to run this python file:
from selenium import webdriver
browser = webdriver.Firefox()
type(browser)
browser.get('http://inventwithpython.com')
However, when I run this using the terminal, I get the following error:
mustafas-mbp:PlayDivya mustafahoda$ python playDivya.py
Traceback (most recent call last):
File "playDivya.py", line 4, in <module>
from selenium import webdriver
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 22, in <module>
import httplib as http_client
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 69, in <module>
from array import array
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so, 2): Symbol not found: __PySlice_AdjustIndices
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
Any help would be super helpful. This is a very simple script and I have no idea why this is happening!
Thanks in advance!
The error says it all :
Traceback (most recent call last):
File "playDivya.py", line 4, in <module>
from selenium import webdriver
.
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so, 2): Symbol not found: __PySlice_AdjustIndices
Reasons and Solution
This issue can arise when you install a new version of python. In those cases you may need to run hash -r python to tell bash to reset the cached location to the python executable.
If hash -r python says too many args then you can use rehash command.
As per the discussion Symbol not found: __PyCodecInfo_GetIncrementalDecoder the issue occurs when Python is updated from Python 2.7.10 to 2.7.11.
If you are using conda package you need to run conda install python=2.7.10 which will solve this problem.
Even downgrading Python to 2.7.10 will also work.
The best solution would be Re-Installing Selenium.
I have Python 3.0.1 and beautifulsoup 4.1.0 but when I try and run from bs4 import BeautifulSoup, I receive this error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named bs4
I have read that some of the versions of beautiful soup don't work with certain versions of Python but because I am unfamiliar and haven't used either before I am unsure of which versions I should download.
I am using Python Splinter to automate a website and to scrape data from it. When I use the default browser mode which is keeping blank in Browser() it opens firefox and completes the written task but, when I use the headless browser 'zope.testbrowser', I get the following error. What should I need to do here?
Traceback (most recent call last):
File "pysplinter.py", line 4, in <module>
browser = Browser('zope.testbrowser')
File "/usr/local/lib/python2.7/dist-packages/splinter/browser.py", line 62, in Browser
raise DriverNotFoundError("No driver for %s" % driver_name)
splinter.exceptions.DriverNotFoundError: No driver for zope.testbrowser
I don't know if this is still relevant, but will post anyway for the benefit of others.
I faced the same issue and my problem was that mechanize module was not installed.
Fix:
pip install mechanize
However, I faced another issue after this.
Explanation
That's the line of code that is failing in browser.py of splinter, but due to except: pass, it is being silently ignored. If executed manually, the root of the problem can be observed:
>>> from splinter.driver.zopetestbrowser import ZopeTestBrowser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rustam/.virtualenvs/python2/lib/python2.7/site-packages/splinter/driver/zopetestbrowser.py", line 19, in <module>
import mechanize
ImportError: No module named mechanize
I just installed Selenium (from source) for Python 2.7.
When I try to import selenium, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\__init__.py", line 16, in <module>
from .selenium import selenium
File "C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\selenium.py", line 19, in <module>
import http.client
ImportError: No module named http.client
What could be causing this? If I remember correctly, http.client is a python 3 module. Why is selenium trying to import it?
Thanks to the help of DSM, I figured it out. Because I had previously ran setup.py with a python3 executable by accident, the selenium build folder was populated with 2to3 converted code. When I later ran python27 setup.py install it ended up using the same build folder for the installation without overwriting its content. I ended up deleting the build folder and trying again, and it works.