Jupyter Notebook In Python - python

I have installed two versions of python in my system such as python 3.6 and python 3.
I am running a program in PyCharm which is running fine while the same script is not running in a Jupyter Notebook. The error shown:
ModuleNotFoundError: No module named 'selenium'
I had installed jupyter using anaconda.
The following are my questions:
How do I run a jupyter notebook for the same script?
Is my notebook not pointing to the same python version that I ran in PyCharm?
If so, how can I change it to the appropriate python version?
from selenium import webdriver
driver = webdriver.Chrome(r'C:\Users\Admin\Desktop\sriyam\chromedriver.exe')
driver.get('https://python.org')

have you install selenium
install it
try
conda install -c conda-forge selenium
if error pops up again
try this
pip install selenium
note:-install it from conda prompt
hope it may help

Related

Unable to use jupyter notebook in VScode

When I run jupyter notebook in VScode, it will show the error message. Could someone tell me how to install the ipykernel. Thank you so much!
The fist line said "Python 2.7.16 64-bit needs install ipykernel."
when I click the install which in the blue icon, it will show that ipykernel can not be installed.
And vscode can not connet to the kernel: Python 2.7.16 64-bit
enter image description here
Please manually install this kernel "ipykernel" in the VS Code terminal: (pip install ipykernel)
If you have more than one python environment, please make sure that the VS Code terminal you are currently using is the environment you need ("Python 2.7.16 64-bit"). (Check python: python --version or pip --version)
If it still cannot install "ipykernel", please try to use another python environment or reinstall python.
Reference: Working with Jupyter Notebooks in Visual Studio Code.

How to install arcpy in spyder anaconda

I want to install the module arcpy in spyder anaconda. I run the following command in Anaconda Prompt: conda install arcpy -c esri, which follows https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/installing-arcpy.htm. But it fails. The message shows as below:
The python version is 3.7.10. I'm also using ArcGIS Desktop 10.7.1.
Does anyone know how to figure this out? Thanks
You need to run Spyder within the ArcGIS Pro conda environment, that is c:\Progra~1\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
See: https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/using-conda-with-arcgis-pro.htm

How to install selenium for Jupyter Notebook?

I have run the command pip install selenium, and it can execute from selenium import webdriver in terminal, but it cannot execute this line in Jupyter Notebook, which shows "ModuleNotFoundError: No module named 'selenium'". Besides, I also copied chromedriver.exec file into the path of my jupyter. Does anyone konw how to solve it?
If you are using the Anaconda navigator to run Jupyter then you need to run the pip install selenium command within the Anaconda prompt.
I believe that your Python environment in Jupyter differs from the Python environment that may be in your PATH.

Unable to start jupyter notebook in visual studio code

I am trying to make a jupyter notebook in visual studio code but I keep getting this:
''Unable to start session for kernel Python 3.8.3 64-bit ('Lenovo':
virtualenv). Select another kernel to launch with.''
I have anaconda installed and the jupyter notebook works fine in the anaconda navigator. I also tried to use python 3.8.3 base:'conda' but it didnt work. I'm using windows 10
This issue also occurs on my computer. The solution is to restore the version number of a dependency package "traitlets" of ipython kernel to 4.3.3.
You could try to use "pip list" to view the version of the module "traitlets" in the current virtual environment. If it shows version 5.0, it is recommended that you use version 4.3.3.
You could reinstall "traitlets 4.3.3" with the following command:
python -m pip install 'traitlets==4.3.3' --force-reinstall
If this command is not available, you could use 'pip' to uninstall traitlets5.0 (pip uninstall traitlets) and then use 'pip' to install traitlets4.3.3.(pip install traitlets==4.3.3)
Reference: Unable to start session for kernel Python.
I had the exact same problem. Fix it by uninstalling the Python extension that is linked to that error message.
If you are using conda to manage your Python environments, activate your target environment at a command prompt, then enter the following:
$ conda install traitlets=4.3.3
This solved the problem for me.

How to make Jupyter Notebook to point to the same Python installation as Terminal on Ubuntu?

I am on a Ubuntu machine. I installed Jupyter Notebook using the following command.
sudo snap install jupyter
But Jupyter cannot find any of the installed python packages which were installed using terminal. I checked if jupyter and terminal are pointing to same python installation using this code.
import sys; print(sys.executable)
Terminal shows this output.
'/usr/bin/python3'
And Jupyter shows this one.
'/snap/jupyter/6/bin/python'
Now I want the jupyter to point the same installation path as the terminal shows. How can I do that?
your jupyter is not placed in default packages location due to installing it with snap. install jupyter with pip this way: pip install jupyter
if you dont have pip then download it. it usually is included in python package

Categories