Infinite loop that fills tmp folder in Ubuntu with Selenium - python

Just created a fresh install of Ubuntu. Installed python and selenium, went to run this code:
#!/usr/bin/env python
from selenium import webdriver
browser = webdriver.Firefox('/usr/bin/')
browser.get('http://www.ubuntu.com/')
browser.close()
browser.quit()
when i run it, it just hangs in the terminal and then when I press Control-C it says:
^CTraceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox('/usr/bin/')
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 127, in __init__
firefox_profile = FirefoxProfile(firefox_profile)
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_profile.py", line 78, in __init__
ignore=shutil.ignore_patterns("parent.lock", "lock", ".parentlock"))
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 189, in copytree
copytree(srcname, dstname, symlinks, ignore)
File "/usr/lib/python2.7/shutil.py", line 192, in copytree
copy2(srcname, dstname)
File "/usr/lib/python2.7/shutil.py", line 130, in copy2
copyfile(src, dst)
File "/usr/lib/python2.7/shutil.py", line 84, in copyfile
copyfileobj(fsrc, fdst)
KeyboardInterrupt
If I don't kill the program and it fills my tmp folder for some reason.
I have tried installing selenium three different times across different VMs, using venv, moving selenium all of the place. I am LOST.
Any help is greatly appreciated!!
EDIT: I removed the '/usr/bin/' per #L3viathan and ran it. My new error is:
Traceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error
Couldn't make anything work anymore so I started up another fresh Ubuntu VM and have only done the following commands.
$ sudo apt-get install python-pip
$ sudo pip install selenium
And then I ran my program and got the geckodriver error. So I downloaded the geckodriver. and moved it to /usr/bin/
$ sudo cp geckodriver /usr/bin/
ran program and get EXACT same error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
raise child_exception
OSError: [Errno 8] Exec format error

Related

Jupyter Notebook 404s when using Anaconda Navigator

Sorry but a bit of a beginner question here. I downloaded Anaconda library that comes with Jupyter Notebook along with a few other programs to hopefully learn Python. Every time I try to open Jupyter Notebook though, the webpage it directs me here localhost:8888/tree and gives me the following error:
404: Not Found error webpage.
Edit: After using the terminal to install pip, I got the following error message:
Exception:
Traceback (most recent call last):
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 387, in _rmtree_u
nsafe
os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Y510P\\AppData\\Loca
l\\Temp\\pip-0tanc911-uninstall\\users\\y510p\\documents\\anaconda\\lib\\site-pa
ckages\\zmq\\backend\\cython\\constants.cp36-win_amd64.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\basecommand.py",
line 215, in main
status = self.run(options, args)
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\commands\install
.py", line 342, in run
prefix=options.prefix_path,
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\req\req_set.py",
line 795, in install
requirement.commit_uninstall()
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\req\req_install.
py", line 767, in commit_uninstall
self.uninstalled.commit()
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\req\req_uninstal
l.py", line 142, in commit
rmtree(self.save_dir)
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\_vendor\retrying
.py", line 49, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\_vendor\retrying
.py", line 212, in call
raise attempt.get()
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\_vendor\retrying
.py", line 247, in get
six.reraise(self.value[0], self.value[1], self.value[2])
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\six.py", line 693, i
n reraise
raise value
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\_vendor\retrying
.py", line 200, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\utils\__init__.p
y", line 102, in rmtree
onerror=rmtree_errorhandler)
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 494, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 384, in _rmtree_u
nsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 384, in _rmtree_u
nsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 384, in _rmtree_u
nsafe
_rmtree_unsafe(fullname, onerror)
[Previous line repeated 5 more times]
File "C:\Users\Y510P\Documents\Anaconda\lib\shutil.py", line 389, in _rmtree_u
nsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Users\Y510P\Documents\Anaconda\lib\site-packages\pip\utils\__init__.p
y", line 114, in rmtree_errorhandler
func(path)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\Y510P\\AppData\\Loca
l\\Temp\\pip-0tanc911-uninstall\\users\\y510p\\documents\\anaconda\\lib\\site-pa
ckages\\zmq\\backend\\cython\\constants.cp36-win_amd64.pyd'
Your error message gives:
Copy/paste this URL into your browser when you connect for the first time, to login with a token:
http://localhost:8891/?token=dcf34cac4a27f8b92397fcec424b228b308a4588f0473fd6
So try that first in your browser and see if the error persist.
what is the web page you're going to . If you're using windows . Go to cmd prompt . type jupyter notebook . If you're in mac os x . go to terminal and type jupyter notebook. LMK if it doesnt work .Also this is the link once you trigger jupyter notebook. :
http://localhost:8888/tree
LMK Know

Launching the browser using SPLINTER throws error

Hi I have tried to run the code which is used to open a browser, enter URL and close the browser(https://splinter.readthedocs.io/en/latest/) using SPLINTER in python. The sample code in the above URL is what I tried.
I got the following errors:
C:\Users\irgfff\Desktop>python browse.py
Traceback (most recent call last):
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 707, in __init__
restore_signals, start_new_session)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-
32\lib\subprocess
.py", line 990, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "browse.py", line 4, in <module>
with Browser() as browser:
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\browser.py", line 63, in Browser
return driver(*args, **kwargs)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\splinter\driver\webdriver\firefox.py", line 48, in __init__
timeout=timeout)
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\firefox\webdriver.py", line 142, in __init__
self.service.start()
File "C:\Users\irgfff\AppData\Local\Programs\Python\Python36-32\lib\site-
packa
ges\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver'
executable needs to be in PATH.
Could you let me know what I need to configure to avoid these errors ?
I am using Python 3.6.1
Firefox Version - 52
SPLINTER version 0.7.5
I have solved this problem. You must add PATH the location of geckodriver and webdriver.
You can download geckodriver(https://github.com/mozilla/geckodriver/releases) here.
good luck

Why i can't run this simple example with selenium?

The script is:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
and this come out:
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/GeniusV/Documents/pythonProject/untitled/hj.py
Traceback (most recent call last):
File "/Users/GeniusV/Documents/pythonProject/untitled/hj.py", line 5, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 103, in __init__
self.binary, timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/extension_connection.py", line 51, in __init__
self.binary.launch_browser(self.profile, timeout=timeout)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 67, in launch_browser
self._start_from_profile_path(self.profile.path)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 90, in _start_from_profile_path
env=self._firefox_env)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
i really don't understand why,is it my python or selenium's problem?
Sounds like a compatibility issue.
Make sure you are using the latest selenium:
pip install --upgrade selenium
And have the latest Firefox installed.

cannot run python MRJob locally

If i understand MRJob correctly, you can simulate hadoop's multi process run using MRJob by running it with
python mrfile.py -r local input.txt
I'm running windows(no choice for now), and when I issue the above command, i'm getting a bunch of mambo jumbo and at the end it tells me :
WindowsError: [Error 2] The system cannot find the file specified
This is the full error. Could someone help?
C:\Users\someuser\Documents\Python_projects\something>python MRJob_parser.py -r loc
al test2.txt
no configs found; falling back on auto-configuration
no configs found; falling back on auto-configuration
creating tmp directory c:\users\someuser\appdata\local\temp\MRJob_parser.someuser.
20150701.211822.496000
writing wrapper script to c:\users\someuser\appdata\local\temp\MRJob_parser.bw401
45.20150701.211822.496000\setup-wrapper.sh
writing to c:\users\someuser\appdata\local\temp\MRJob_parser.someuser.20150701.211
822.496000\step-0-mapper_part-00000
> sh -ex setup-wrapper.sh 'c:\Users\someuser\Documents\python_venv\something_Project\
Scripts\python.exe' MRJob_parser.py --step-num=0 --mapper 'c:\users\someuser\appd
ata\local\temp\MRJob_parser.someuser.20150701.211822.496000\input_part-00000' > c
:\users\someuser\appdata\local\temp\MRJob_parser.someuser.20150701.211822.496000\s
tep-0-mapper_part-00000
Traceback (most recent call last):
File "MRJob_parser.py", line 18, in <module>
Extractor.run()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\job.py", line 461, in run
mr_job.execute()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\job.py", line 479, in execute
super(MRJob, self).execute()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\launch.py", line 151, in execute
self.run_job()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\launch.py", line 214, in run_job
runner.run()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\runner.py", line 464, in run
self._run()
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\sim.py", line 173, in _run
self._invoke_step(step_num, 'mapper')
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\sim.py", line 260, in _invoke_step
working_dir, env)
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\local.py", line 147, in _run_step
procs_args, output_path, working_dir, env)
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\local.py", line 250, in _invoke_processes
cwd=working_dir, env=env)
File "c:\Users\someuser\Documents\python_venv\something_Project\lib\site-packages\m
rjob\local.py", line 73, in _chain_procs
proc = Popen(args, **proc_kwargs)
File "C:\Python27\Lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\Lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
C:\Users\someuser\Documents\Python_projects\something>
From https://github.com/Yelp/mrjob:
# locally
python mrjob/examples/mr_word_freq_count.py README.rst > counts
My guess is that you don't have to pass in the local runner option and that's causing some kind of error.

Error while running Plone 4.2 instance fg on Window

While running buildout on window with Python 2.6 for Plone 4.2, All went fine. but while running instance on foreground it give me this window specific (presume) error about some file missing.
I remember on older version of Plone for installing PyWin type libary, I had to copy some dll file to window system file and I also done same for this. still I am having this error.
Any suggestion/advise would great help.
Thank for taking your time.
D:\rcseng\buildout>bin\instance fg
Traceback (most recent call last):
File "D:\rcseng\buildout\bin\instance-script.py", line 258, in <module>
+ sys.argv[1:])
File "d:\rcseng\buildout\eggs\plone.recipe.zope2instance-4.2.8-py2.6.egg\plone
\recipe\zope2instance\ctl.py", line 614, in main
c.onecmd(' '.join(options.args))
File "D:\Python26\lib\cmd.py", line 219, in onecmd
return func(arg)
File "d:\rcseng\buildout\eggs\zdaemon-2.0.7-py2.6.egg\zdaemon\zdctl.py", line
588, in do_fg
self.do_foreground(arg)
File "d:\rcseng\buildout\eggs\plone.recipe.zope2instance-4.2.8-py2.6.egg\plone
\recipe\zope2instance\ctl.py", line 550, in do_foreground
self._exitstatus = subprocess.call(command, env=env)
File "D:\Python26\lib\subprocess.py", line 470, in call
return Popen(*popenargs, **kwargs).wait()
File "D:\Python26\lib\subprocess.py", line 623, in __init__
errread, errwrite)
File "D:\Python26\lib\subprocess.py", line 833, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Categories