I'm new in python and Linux also. I try to install selenium in python 3.7
but i got the error:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.ubuntu.com/')
output
Traceback (most recent call last):
File "test.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 29, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 26, in <module>
from .webelement import WebElement
File "/usr/local/lib/python3.7/dist-packages/selenium/webdriver/remote/webelement.py", line 37, in <module>
from StringIO import StringIO as IOStream File
"/usr/lib/python3.7/StringIO.py", line 40
raise ValueError, "I/O operation on closed file"
^ SyntaxError: invalid syntax
you need to downgrade to python 3.6
Or if you do not have gecko driver go through following steps.
wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
sudo sh -c 'tar -x geckodriver -zf geckodriver-v0.23.0-linux64.tar.gz -O > /usr/bin/geckodriver'
sudo chmod +x /usr/bin/geckodriver
rm geckodriver-v0.23.0-linux64.tar.gz
Related
I am working on a scraping project and have all recent downloads of python (3.9.5), VScode, Selenium, and BeautifulSoup. All the modules seem to be working correctly and I receive no errors when running the code. However, the URL is not opened by the web driver when I run the code - nothing happens? Please assist me in what I am missing so I am able to see my control window/display.
Code:
import csv
from bs4 import BeautifulSoup
from selenium import webdriver
# Startup the webdriver
driver = webdriver.Chrome()
url = 'https://www.amazon.com'
driver.get(url)
Output:
[Running] python -u "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/site-packages/
ScrapingTest.py"
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/element.py:16:
UserWarning: The soupsieve package is not installed. csS selectors cannot be used.
'The soupsieve package is not installed. CSS selectors cannot be used.'
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ScrapingTest.py",
line 2, in <module>
from bs4 import BeautifulSoup
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/_init_-py",
line 32, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/builder/
_init_.py", line 7, in <module>
from bs4.element import (
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/element.py",
line 19, in <module>
from bs4. formatter import (
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/formatter.py",
line 1, in <module>
from bs4.dammit import EntitySubstitution
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 68, in <module>
class EntitySubstitution(object):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 97, in EntitySubstitution
CHARACTER_TO_HTML_ENTITY_RE) = _populate_class_variables ()
File "/Library/Frameworks/Python. framework/Versions/3.9/lib/python3.9/site-packages/bs4/dammit.py",
line 83, in _populate_class_variables
character = chr(codepoint)
ValueError: chr() arg not in range (256)
[Done] exited with code=1 in 0.198 seconds
The error message states that:
UserWarning: The soupsieve package is not installed. css selectors cannot be used.
Hence, installing the soupsieve package using pip install soupsieve should fix the error.
After installing Odoo 12 Community in Ubuntu 16.04 from https://www.odoo.yenthevg.com/installing-odoo-12-enterprise-ubuntu/
I am getting following error:
Traceback (most recent call last):
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo-bin", line 5, in <module>
import odoo
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/__init__.py", line 89, in <module>
from . import modules
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/modules/__init__.py", line 8, in <module>
from . import db, graph, loading, migration, module, registry
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/modules/graph.py", line 10, in <module>
import odoo.tools as tools
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/tools/__init__.py", line 8, in <module>
from .config import config
File "/home/odoodev/NewOdoo12e/odoo_12.0+e.latest_all/data/usr/lib/python3/dist-packages/odoo/tools/config.py", line 18, in <module>
from passlib.context import CryptContext
File "/usr/local/lib/python3.5/dist-packages/passlib/context.py", line 20, in <module>
from passlib.registry import get_crypt_handler, _validate_handler_name
File "/usr/local/lib/python3.5/dist-packages/passlib/registry.py", line 11, in <module>
from passlib.utils import is_crypt_handler
File "/usr/local/lib/python3.5/dist-packages/passlib/utils/__init__.py", line 32, in <module>
from passlib.utils.compat import add_doc, b, bytes, join_bytes, join_byte_values, \
ImportError: cannot import name 'b'
I already have Odoo 12 Enterprise version, but after installing Odoo 12 Community, getting same error in Odoo 12 Enterprise.
Please try this.
sudo pip3 install passlib==1.6.5
sudo -H pip3 install --upgrade pip
sudo -H pip3 install pipenv
I have both python 2.7.16 and python 3.5.2 installed on my ubuntu 16.04 LTS and numpy used to work well on both of them but recently something went wrong with numpy on python 2 while it still running smoothly on python 3
I have tried to uninstall and install the numpy package and this did not fix anything
The exact stdout I am getting is as follow:
python -c "import numpy as np"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/home/ahmed/.local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: liblapack.so.3gf: cannot open shared object file: No such file or directory
Indeed Linux error while loading shared libraries: cannot open shared object file: No such file or directory resolved the problem. I had have only to do the following:
sudo find / -iname liblapack.so.3gf
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:*path_to_lib_as_found*
sudo ldconfig -v
Thanks to Abdur Rehman for the hint
Cheers.
Does your Ubuntu have the latest lapack library? Try installing sudo apt install liblapack3gf liblapack-dev. Sometimes you need to run sudo ldconfig after the install.
I am using Selenium and Virtualenv in Ubuntu14.04 to scrape some code on webpage. After making a virtualenv directory, while activating virtualenv using
source bin/activate,
I installed selenium, headless firefox, pyvirtualdisplay and firefox geckodriver.
I installed headless firefox according to here.
And I also Found out that there are different python2.7 folders at
"/usr/lib/python2.7/" and "~/ladder_selenium/lib/python2.7" (ladder_selenium is the Virtualenv directory)
and after I ran a python code which contains
from selenium import webdriver
, the error below happens.
Traceback (most recent call last):
File "predict.py", line 12, in <module>
driver = webdriver.Firefox()
File "/home/heyjude/ladder_selenium/local/lib/python2.7/site-packages/selenium/webdriver/f
self.service.start()
File "/home/heyjude/ladder_selenium/local/lib/python2.7/site-packages/selenium/webdriver/c
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Could you tell me what to fix?
EDIT for the COMMENT BELOW:
(ladder_selenium) heyjude#ladder-selenium:~$ export DISPLAY=:99
(ladder_selenium) heyjude#ladder-selenium:~$ firefox
XPCOMGlueLoad error for file /opt/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.
I was trying out QuotesSpider example given in docs (page# 5, here), but am having a hard time to get it running. I installed scrapy from conda in the root environment. I am on Ubuntu 14.04, 64 bit machine. As soon as I run the given code snippet with the following command:
$ scrapy runspider quotes_spider.py -o quotes.json
I get the following error:
Traceback (most recent call last):
File "/home/rip/miniconda2/bin/scrapy", line 4, in <module>
import scrapy.cmdline
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/__init__.py", line 34, in <module>
from scrapy.spiders import Spider
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/home/rip/miniconda2/lib/python2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/home/rip/miniconda2/lib/python2.7/site-packages/lxml/html/__init__.py", line 54, in <module>
from .. import etree
ImportError: libiconv.so.2: cannot open shared object file: No such file or directory
As apparent, an object file seems to be missing. Do I have to build scrapy from source, or is there an alternative?