Jupyter notebook python version different from environment python version - python

I wanted to run jupyter notebook with python: 3.7.10 so I created a virtual env and activated it using anaconda. Then when I run Jupyter notebook, it still uses python 3.8.8. How can I change the python version used by jupyter notebook?
Thank you for your help in advance.

You have probably typed jupyter notebook in the command prompt and it opened.
Actually jupyter and notebook are two modules that you need to install on your virtual environment. So that you can leverage jupyter notebook from that environment.
In your case since you didn't had them it started from the one having.
Now the way I suggest to start jupyter from a particular environment is from the navigator itself as shown in the figure below.
Select your environment and then install and launch jupyter notebook.
If it doesn't work you can try integrating conda with jupyter notebook and run your environment directly from jupyter notebook using the package nb_conda. Check this 4 min video youtu.be/Ro9l0eapoJU for the process.

Related

How can I get a Jupyter Notebook to see the modules in the environment that it was opened in?

I am attempting to import cartopy into a notebook but am running into issues. If I do a "conda install cartopy" in my base environment, I get the frozen/flexible solve issue (https://github.com/conda/conda/issues/9367). When I open a new environment and do a "conda install cartopy", it seems like everything works. "conda list" shows version 0.18.0 in that environment. Then I open a Jupyter Notebook from within that environment and try to import it into the notebook but originally got the response "no module named cartopy". I tried fiddling with my environments and settings based on feedback on this page (In which conda environment is Jupyter executing?), but now the error is "no module named numpy"! Can someone please help me understand why the notebook isn't seeing these modules? Thank you.
Are you certain that numpy is installed in this new environment?
Given that you are using the Anaconda distribution of Python, you should be able to view/configure your environment and it's installed modules using the Anaconda Navigator. Here you can see a full list of all installed modules, and via the terminal/console, launch a Jupyter Notebook from not only within a specific environment, but within a specific directory!
On the left hand side, you can choose the environment that you want to use to start Jupyter Notebook, and on the right you can view all of the installed modules in that environment. Make sure that jupyter, numpy, and cartopy are all listed as installed packages.
To make sure that I am launching Jupyter from my desired environment, I always launch it directly from the terminal. I "Open Terminal" with my environment, "cd" into the directory that I want to use, and then use the jupyter notebook or jupyter lab command.

Just installed Jupyter using Anaconda but can't run it using terminal. Says command not found

I just bought my very first Mac after using Windows my entire life and have been trying to install things. I am also still kind of a beginner at programming.
I installed Anaconda for Python 2.7 version, and then I installed the 3.7 version right after.
I tried going to terminal and typing jupyter notebook but it says:
zsh: command not found: jupyter
I am able to launch a jupyter notebook (I think) when I search for jupyter notebook in spotlight and executing the top hit.
I've been reading a lot on forums about this issue and see a lot of people talking about PATH which I am not really sure about.
I've seen people also post their which python information and theirs seem very different from mine:
which python3
usr/bin/python3
which python
usr/bin/python
Any help would be appreciated! Still learning how to set up this Mac. Thank you.
You might want to refer to this link https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html
3.1.2. Change Jupyter Notebook startup folder (Mac OS)
To launch Jupyter Notebook App:
Click on spotlight, type terminal to open a terminal window.
Enter the startup folder by typing cd /some_folder_name.
Type jupyter notebook to launch the Jupyter Notebook App The notebook interface will appear in a new browser window or tab.
From what I can understand you are not changing to the startup directory of Jupyter.
You need to add jupyter to your path.
In your terminal, type in the following command:
export PATH="/PUT JUPYTER PATH HERE:$PATH"
Then try jupyter notebook
Reasoning: If installing using pip install --user, you must add the user-level bin directory to your PATH environment variable in order to launch jupyter lab

Is there a way to run Jupyter Notebooks Without Anaconda?

I deleted Anaconda because it was causing more issues than solving in working with other editors like Sublime, PyCharm, etc...
In class, we have a lot of Jupyter notebooks. Is there a program that allows me to run Jupyter Notebooks just like Anaconda allowed me to? Basically the same User Interface where Cntrl + Enter runs a block a code?
Thanks.
Edit: I figured it out. I needed to downgrade Python from 3.8 to 3.7
Jupyter can be installed separately to Anaconda using pip via pip3 install jupyter - see the Jupyter page for more information.

Pycharm jupyter notebook wsl: Jupyter package is not installed

I would like to use Jupyter notebook inside Pycharm. The project interpreter is a python2.7 from a virtual environment inside WSL (ubuntu 18.04).
The Jupiter package is correctly installed inside the virtual environment (I can run it by jupyter notebook).
My problem is that when I want to use Jupyter notebook inside Pycharm, I get the following error: Run Error Jupyter package is not installed (see picture).
Any idea what's going on here?
I had this problem in Python 3. Below are the steps I took to resolve the issue; I believe they should resolve the issue for you too:
I had Jupyter Lab installed. Pycharm only works with Jupyter Notebook. Long story short, if you have Jupyter Lab installed you need to uninstall all your packages using:
$ pip freeze | xargs pip uninstall -y
Restart your computer
Follow Jupyter Notebook installation instructions
Make sure WSL is set up through pycharm instructions: wsl pycharm instructions
In Pycharm, open an .ipynb file. Click the dropdown that says "Managed Jupyter server" It's right above the text editor. Select "configure Jupyter server". Check configured server.
In your wsl terminal, type jupyter notebook. Copy and paste the text that looks like: http://localhost:8888/?token=874asdf687asd6fasd8f74ds6f4s9d8f7sddf into the cofigured server box in Pycharm.
That's it. You should be able to run the jupyter cells in pycharm now.
I have Pycharm 2020.3 For me the issue was I was using a virtual environment with "inherit global site packages." I had Jupyter installed in global site packages but NOT the virtual environment.
Once I installed Jupyter within the virtual environment Jupyter notebook worked. Not sure why inheriting Jupyter from global packages wasn't working for me.
The above solution using a designated url with token seems to work with older versions of PyCharm. A simpler solution is to upgrade to the latest PyCharm. I no longer had an issue with the auto server using PyCharm 2019.3.2 (Mac)
I had this problem with Datalore plugin enabled on 2020.2 linux, running on bare metal but displaying to a remote X server (probably doesn't matter). My solution was to disable the Datalore plugin (it's enabled for professional pycharm by default).
This way I was still able to use the "managed" auto-start version with better integration / debugging vs the "configured" option (or at least with less hassle).
Note since it's been a year, my problem is probably different than OP.
This happened for me, when the interpreter was a remote one. I fixed this by changing the interpreter to one from a local env.
This can be done by selecting the Configure Jupyter Server.
I also meet this problem,and i solved it
i create the new project with the global sit-packages like below
then i meet the problem
i create the new project with no global sit-packages and install jupyter notebook in the virtualenv
then the problem is gone

jupyter notebook - change kernels isn't working

I have multiple kernels in my notebook, but when changing the kernel it doesn't really change it and still run the original kernel (which I first open the notebook with).
For example, I run the notebook with python 3.6 environment, but when changing the kernel to python 2.7 it stayed with python 3.6.
I'm changing the kernels via jupyter GUI (kernel -> change kernel) and check the path of python using:
!which python
In all environments I installed ipykernel but it doesn't matter which kernel I'm choosing, the path stayed the same (the path of the original kernel which I used to run the notebook).
I had the same issue, launching jupyter from the terminal after activating the environment worked for me, I followed the steps as below:
Open anaconda prompt
Activate environment with conda activate EnvName
Launch jupyter with jupyter lab

Categories