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.
Related
I am unable to import psutil when I activated python on my venv, its gives the following error message, which I cant resolve.
I tried to uninstall psutil and install psutil again but it still returns the same error.
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/__init__.py", line 157, in <module>
from . import _psosx as _psplatform
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psosx.py", line 16, in <module>
from . import _psutil_osx as cext
ImportError: dlopen(/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so, 2): Symbol not found: _kIOMasterPortDefault
Referenced from: /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Expected in: flat namespace
in /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Will appreciate if anyone knows how to resolve this issue, thanks.
Does it raise the same error when you activate the venv, open the virtualenv python interpreter and import psutil?
Another cause I can think of is when you name your script psutil.py and within that script you try to import the psutil module.
(see the post of Yong Wang: airflow error:AttributeError: module 'airflow.utils.log' has no attribute 'file_processor_handler')
Recently, I have installed Cassandra. 3.6
After installation, I got an error.
Connection error: ('Unable to connect to any servers', {'127.0.0.1': TypeError('ref() does not take keyword arguments',)})
To solve this, I have followed
pip install cassandra-driver==2.7.2
pip install cassandra-driver
export CQLSH_NO_BUNDLED=true
And my python version is 2.7
right Now, when I run cqlsh, I'm getting following error
Traceback (most recent call last):
File "/usr/bin/cqlsh.py", line 167, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling
File "/usr/lib/python2.7/dist-packages/cqlshlib/cql3handling.py", line 17, in <module>
from .cqlhandling import CqlParsingRuleSet, Hint
File "/usr/lib/python2.7/dist-packages/cqlshlib/cqlhandling.py", line 21, in <module>
from cassandra.metadata import cql_keywords_reserved
ImportError: cannot import name cql_keywords_reserved
How can I solve this error? How can I run cassandra withour errors?
You are seeing CASSANDRA-11840, which occurs with older versions of the driver with Python 2.7.12+.
To work around it, either
1.) Upgrade to Cassandra 3.8+, which bundles a driver version that does not have this problem.
or
2.) Make your environment/PATH use Python <= 2.7.11
or
3.) CQLSH_NO_BUNDLED=1 as you guessed, but install a version of the driver that has the fix (cassandra-driver >= 3.4.0).
I am trying to use selenium in python and I am getting the following error:
Symbol not found: __PyCodecInfo_GetIncrementalDecoder
>>> from selenium import webdriver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/selenium/__init__.py", line 18, in <module>
from selenium import selenium
File "/usr/local/lib/python2.7/site-packages/selenium/selenium.py", line 25, in <module>
import httplib as http_client
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
>>>
OSX 10.11.1
python 2.7.10
I can't figure out if this is an El Capitan issue, python issue. Tried brew doctor and system is ready.
It turned out it was a python issue, after installing a new version of python. Running this solved the issue:
hash -r python
This problem is most probably caused by Brew Installed python.
The python official website provides downloads for macOS, you should download and install the official package.
The official installer will fix the python link automatic, then issue solved.
I'm trying to work through http://blog.likewise.org/2013/04/webdriver-testing-with-python-and-ghostdriver/. My development environment is a usb drive on win7. I have phantomjs.exe on:
f:/phantomjs.exe
Using the python REPL I have done the following based on the article:
>>> from selenium import webdriver
>>> driver = webdriver.PhantomJS(executable_path="F:\phantomjs.exe")
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "F:\envs\r1\lib\site-packages\selenium\webdriver\phantomjs\webdriver.py", line 50, in __init__
self.service.start()
File "F:\envs\r1\lib\site-packages\selenium\webdriver\phantomjs\service.py", line 66, in start
raise WebDriverException("Unable to start phantomjs with ghostdriver.", e)
WebDriverException: Message: 'Unable to start phantomjs with ghostdriver.' ; Screenshot: available via screen
How can I fix this?
Following Can't run PhantomJS in python via Selenium, I uninstalled selenium from my virtualenv and ran:
pip install selenium==2.37
So far this has been working for me , although the above articles indicates there are some problems at least.
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.