Error while installing Selenium in pip3 - python-3.x

I am attempting to install selenium, and yet there seems to be a problem:
I ran pip3 install -U selenium, and I get:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.5/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/usr/local/lib/python3.5/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.5/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.5/site-packages/pip/wheel.py", line 378, in move_wheel_files
clobber(source, dest, False, fixer=fixer, filter=filter)
File "/usr/local/lib/python3.5/site-packages/pip/wheel.py", line 317, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python3.5/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 231, in makedirs
makedirs(head, mode, exist_ok)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/selenium'
Despite this message, I can proceed and run selenium in python3, and a command like
from selenium import web driver
browser = webdriver.Firefox()
will return
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/common/service.py", line 71, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
What do I need to do?

It can also be done without executing pip as superuser (which you should, at least, try not to):
Create the directory:
sudo mkdir /usr/local/selenium
Give yourself ownership of the directory:
chown your_username /usr/local/selenium
Install Selenium:
pip3 install -U selenium

Did you try to run pip install as a super user? It's common to have PermissionError when you miss the sudo. If you didn't, try sudo pip3 install -U selenium.

Related

Jupyter notebook is not opening

I have installed anaconda package and my pc has already one package installed "root(data analysis package)".
So after installing anaconda I wanted to open jupyter notebook so I type "jupyter-notebook" in the terminal but somehow I am getting following error.
Could you please provide me a solution for this? Thanks.
the error
Traceback (most recent call last):
File "/home/souvik/anaconda3/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 264, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.initialize(argv)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 88, in inner
return method(app, *args, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/notebook/notebookapp.py", line 2143, in initialize
super().initialize(argv)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/traitlets/config/application.py", line 88, in inner
return method(app, *args, **kwargs)
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 239, in initialize
self.migrate_config()
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/application.py", line 165, in migrate_config
migrate()
File "/home/souvik/anaconda3/lib/python3.9/site-packages/jupyter_core/migrate.py", line 245, in migrate
with open(os.path.join(env['jupyter_config'], 'migrated'), 'w', encoding='utf-8') as f:
PermissionError: [Errno 13] Permission denied: '/opt/root/6.26.10-install/etc/notebook/migrated'*
I could not find any solution in google for this.
After a glimpse at the error Message,
You seem not to have access to /opt/root/6.26.10-install/etc/notebook/migrated
How did you install the anaconda? (globally or on root?)
since you are currently running as user "souvik"
Try running:
sudo jupyter-notebook --allow-root
Then post back the results.
In case the above command started jupypter-notebook successfully,
we can change the ownership of /opt/root/6.26.10-install/etc/notebook/from rootto you (souvik) using chown.

Django app dependencies on Shared hosting(Cpanel)

I've been trying to deploy an Django app in a Shared hosting with Cpanel.
But every time that I tried to install google-cloud-automl dependency I get this message on the server
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-vnlg73ta/grpcio/setup.py", line 212, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-build-vnlg73ta/grpcio/setup.py", line 172, in check_linker_need_libatomic
stderr=PIPE)
File "/opt/alt/python37/lib64/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "/opt/alt/python37/lib64/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: 'cc'
Any idea how I may install this dependency?
It was the pip version used on my virtualenv so after updated it worked

I am getting an error "No module named 'virtualenv.__main__'; 'virtualenv' is not a package " while building an apk file using buildozer

Exception in thread background thread for pid 29351:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/sh-1.12.14-py3.6.egg/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/sh-1.12.14-py3.6.egg/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/usr/local/lib/python3.6/dist-packages/sh-1.12.14-py3.6.egg/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/usr/local/lib/python3.6/dist-packages/sh-1.12.14-py3.6.egg/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /usr/local/bin/virtualenv --python=python3 venv
STDOUT:
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in
from virtualenv.main import run_with_catch
ModuleNotFoundError: No module named 'virtualenv.main'; 'virtualenv' is not a packagestrong text
Did you install virtualenv, when not consider installing it with
pip3 install --user virtualenv
You can remove --user when you are in a virtual environment already

OSError: [Errno 8] Exec format error - wkhtmltopdf & pydf

I want to use pydf to generate a pdf in Python 3. I tested it out in terminal (Mac) and received the below error. Does anyone know why and what to do?
If possible, I would like to stick with pydf and not have to move to another library.
.
I downloaded the Mac wkhtmltopdf version from https://wkhtmltopdf.org/downloads.html
As well as pydf from pip install python-pdf
>>> import pydf
>>> pydf.generate_pdf('hello')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/wkhtmltopdf.py", line 145, in generate_pdf
p = _execute_wk(*cmd_args, input=html.encode())
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/wkhtmltopdf.py", line 30, in _execute_wk
return subprocess.run(wk_args, input=input, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 453, in run
with Popen(*popenargs, **kwargs) as process:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pydf/bin/wkhtmltopdf'
>>>
This is because the binary which is packaged with python-pdf is for linux and will not execute on MacOS, this explained briefly in the README.
Luckily the solution is easy, you need to install wkhtmltopdf via homebrew or similar, then set the WKHTMLTOPDF_PATH environment variable to point to it.
In my case that's
export WKHTMLTOPDF_PATH=/usr/local/bin/wkhtmltopdf

Spyder :Error ocurred while starting the kernel

An error occurred while starting the kernel in Spyder
The error is:
Traceback (most recent call last):
File "G:\Anaconda\lib\site‑packages\spyder\plugins\ipythonconsole.py", line 1572, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle)
File "G:\Anaconda\lib\site‑packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "G:\Anaconda\lib\site‑packages\jupyter_client\connect.py", line 547, in write_connection_file
kernel_name=self.kernel_name
File "G:\Anaconda\lib\site‑packages\jupyter_client\connect.py", line 212, in write_connection_file
with secure_write(fname) as f:
File "G:\Anaconda\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "G:\Anaconda\lib\site‑packages\jupyter_client\connect.py", line 102, in secure_write
with os.fdopen(os.open(fname, open_flag, 0o600), mode) as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Roaming\\jupyter\\runtime\\kernel‑bd9c021b8392.json'
(Spyder maintainer here) To fix this problem please open the Anaconda Prompt and run there
conda update --all
Turn of fire wall and Run spyder as an administrator.

Resources