Can't open Jupyter notebook with Anaconda - python

I just installed Anaconda, in my Surface Pro 3, with Windows 10, using the provided installer for 64-bit. When I try to launch "jupyter notebook" I always get the following message:
Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation.
All rights reserved.
C:\Users\Carlos>jupyter notebook Traceback (most recent call last):
File "C:\Program
Files\Anaconda3\Scripts\jupyter-notebook-script.py", line 3, in
import notebook.notebookapp
File "C:\Program
Files\Anaconda3\lib\site-packages\notebook\notebookapp.py", l ine 32,
in
from zmq.eventloop import ioloop
File "C:\Program Files\Anaconda3\lib\site-packages\zmq__init__.py",
line 34, in
from zmq import backend
File "C:\Program
Files\Anaconda3\lib\site-packages\zmq\backend__init__.py", l ine 40,
in
reraise(*exc_info)
File "C:\Program
Files\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", lin e 34, in
reraise
raise value
File "C:\Program
Files\Anaconda3\lib\site-packages\zmq\backend__init__.py", l ine 27,
in
_ns = select_backend(first)
File "C:\Program
Files\Anaconda3\lib\site-packages\zmq\backend\select.py", lin e 26, in
select_backend
mod = import(name, fromlist=public_api)
File "C:\Program
Files\Anaconda3\lib\site-packages\zmq\backend\cython__init__ .py",
line 6, in
from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
I tried to uninstall/install again several times, I tried to install it just for me or for all the users in the computer, I tried to update anaconda first...with no success. Any clue?
Thanks!

It seems to be a problem with the default installation of Anaconda. So, I removed the pyzmq package, which seems to be the problematic one.
This is what I have done:
conda uninstall pyzmq (This also removes jupyter related packages!)
conda install pyzmq (to reinstall it)
conda install jupyter (to reinstall jupyter related packages)
Now I can open Jupyter Notebook!

I also got somewhat same error today on my system and now it got resolved by following solution.
Please add following in the path variable, it will be resolved thereafter (I just checked):
C:\ML\installed_tools\anaconda3 (was already present)
C:\ML\installed_tools\anaconda3\Scripts (was already present)
C:\ML\installed_tools\anaconda3\Library\bin (added now)
C:\ML\installed_tools\anaconda3\Library\mingw-w64\bin (added now)
Refer this link for exact exception which I got (with exact versions of the modules) and resolved thereafter. Above exception might be of older anaconda version but solution should be same.

Here is what worked for me (You have to upgrade pyzmq):
python -m pip install --upgrade pip
pip install --upgrade pyzmq
After that it worked fine.

There are multiple options to fix this, i am still investigating on the root cause. However, you can try the solution given below..
if the Jupyter notebook version is 5.1.0 & above, you can uninstall using << conda uninstall notebook >> and then install Jupyter notebook from Anaconda Command prompt using << conda install notebook=5.0.0 >> This will help you launch the Anaconda Navigator from base environment itself.
Second option..,
Create another environment in conda << conda env create -f {name of yml file}.yml >>.
After creating, open the Anaconda navigator UI, switch the environment to the newly created environment and launch Jupyter ( this will work even with latest Jupyter notebook version 5.3.7 as well), it will work.
I am still investigating why the latest version is not opening with the base environment. however, we can use solution 1 or 2 based on your preference.

There may be access privileges issues with installing in the \Program Files folder.
I have Anaconda3 and installed into the root C:\ directory and had no problems with dll file installation like you have.
Try installing Anaconda3 as Anaconda3 with no spaces directly as its own folder in the C:\ directory.
Once installed, you can use the Anaconda Cheat Sheet to get started quickly to verify that installation works by going into the Anaconda3 folder and (if you are on Windows) SHIFT+RIGHT-CLICK-MOUSE and it will give you menu with open to open Command [Line] Window directly in that directory of Anaconda3. Open the Command Line window and run the commands from the Anaconda Cheat Sheet to quickly get started:
http://conda.pydata.org/docs/_downloads/conda-cheatsheet.pdf
You will need to follow instructions to create virtual Python development environment/folder within the Anaconda3. Then you will need to make sure you install the Jupyter Notebook into that virtual env/folder. Of course you will need to "activate" that virtual env after installing.
I hope this helps.

Regarding the issue of opening Jupyter Notebook with Anaconda, I was having this error message:
[W 12:34:52.309 LabApp] Permission to listen on port 8984 denied.
[C 12:34:52.309 LabApp] ERROR: the notebook server could not be started because no available port could be found.
It was trying each port but failing because of no permission. Running jupyter on a custom port fixed the problem:
jupyter notebook --port 9999

I just wasn't able to start Jupyter notebook directly after the installation.
Using a new terminal window was the solution for me.

Related

Jupyter-lab not found

I'm on macOS Big Sur, running python3.9 installed with homebrew. I had some path link problem with my old jupyter so I uninstalled it. I couldn't remember how I installed the jupyter in the past so I manually rm jupyter files in /usr/local/bin and /usr/local/Cellar.
Then I reinstalled jupyter-lab using pip3 install. Then when I run jupyter lab, it gave me traceback:
File "/usr/local/bin/jupyter", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/jupyter_core/command.py", line 285, in main
command = _jupyter_abspath(subcommand)
File "/usr/local/lib/python3.9/site-packages/jupyter_core/command.py", line 124, in _jupyter_abspath
raise Exception(
Exception: Jupyter command `jupyter-lab` not found.
However, I've checked the jupyter notebook command. It worked fine. It seems I'm only missing the jupyter-lab file. What should I do?
Did you add /.local/bin to the environment path?
export PATH=$PATH:~/.local/bin

Jupyter wont launch from Anaconda3 on Windows10

I've recently installed Anaconda3 32bit version on Windows 10 but Jupyter won't launch.
I've updated anaconda using conda and everything looked ok with all packages including Jupyter downloading.
I've added the path to environmental variables.
I've tried to run jupyter notebook from cmd prompt but still get the same error message.
Trace:
Traceback (most recent call last): File "C:\Users\Edward\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in
from notebook.notebookapp import main
ModuleNotFoundError: No module named 'notebook.notebookapp'; 'notebook' is not a package
If jupyter is installed on your system you can also use cmd to open i as:
jupyter notebook
If not then u can use pip to install jupyter:
pip install jupyterlab
or
pip install notebook
Then you can use cmd to open.
Maybe you did not download the latest version of Python.
Try downloading Python 3.9 first and see.
You can also download jupyter notebook from your OS terminal.
Thanks, but I have tried these ideas. The root of the problem (pun not intended!) is in the path definitions I think. I have tried adding path definitions. But things that used to work fine like running pip from the C:\ prompt no longer do. So I have given up on Anaconda and now use Visual Studio Code for everything, including running a Jupyter Notebook.
Don't know why the system path definition doesn't work. If I go to the directory containing pip it runs ok.
Many Thanks

Pandas and Jupyter not found after upgrading to Catalina

I just updated my macOS to Catalina and I can't run python or open a jupyter notebook from terminal anymore. As an example, I get error message "ImportError: No module named pandas" when running my python code, and I get
zsh: command not found: jupyter
when running
jupyter notebook
This issue has brought me to anaconda (I would love someone to explain me why. Does python need anaconda to be ran?). I have tried several suggestions from https://github.com/ContinuumIO/anaconda-issues/issues/10998, e.g. I have tried copying folder "anaconda3" from "Relocated items" folder to "Users//", then
export PATH=''/Users/<username>/anaconda3/bin:$PATH"
but I get either
dquote>
or
zsh: /Users//Applications/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory
I then tried to reinstall Anaconda using the graphic installer (from https://www.anaconda.com/distribution/#macos) following advice from someone from the anaconda team (https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/) (I changed installation location to a folder I created in /Users//) but I still get the same error messages when running python3 or jupyter notebook.
How can successfully run python and jupyter notebook with macOS Catalina?
After installed macOS Catalina, we can switch the terminal from bash to zsh. There are many advantages from using zsh instead of bash, but One of the issues with zsh is some of the frameworks (jupyter notebook,conda) are not supported directly. Once I typed jupyter notebook in terminal to run it. It displayed “zsh: no such file or directory”.
The solver is simple but very difficult to find online.
If jupyter was already installed before the update and stopped working after zsh, you should be able to fix it by:
1.open zshrc in terminal by typing: open .zshrc or $open .zschrc
2. add the following line at the end of the file:
source ~/.bash_profile
It will ask zsh to use all the information from bash like the path of jupyter.
Hope it can help you out!
I'm answering to my own question in case it can help others ;)
I found my answer here: https://medium.com/#singhaniatanay18/mac-os-catalina-update-zsh-instead-of-bash-d688f68f70b8
(see comments as well)
Mac OS BigSur:
Uninstall Anaconda:rm -f Anaconda-Navigator.app
re-install pip3 install jupyterlab
I just updated to Catalina, two days before Big Sur release.. oh well.
Catalina came with changes to security and bash, that will remain for future releases. So Catalina moves your anaconda3 folder to /Users/Shared/Previously Relocated Items/Security/anaconda3 I tried to move it back to home directory, but that didn't work. So I deleted it, and reinstalled Anaconda using the command line installer Not the GUI installer, and it worked for me. You can follow instructions here and use /Users/me/anaconda3 folder as recommended here.
Here are the commands that worked for me,
shasum -a 256 /Users/username/anaconda3 . Although not sure it did anything
bash ~/Downloads/Anaconda3-2020.02-MacOSX-x86_64.sh or whatever the name of the command line installer from Conda in your Download folder, or wherever else you downloaded it.
Use sudo in front of the command if permission was denied, then enter your log in password for your Mac
source /Users/username/anaconda3/bin/activate conda init zsh
sudo conda init zsh then enter your Mac's password.
You should be all set now, and all commands like ipython, conda info, jupyter notebook, pyspark will all work.
The last command will make step3 command persist i.e. initialize conda base environment, such that you can run conda, ipython, jupyter notebook the next time you use terminal.
Install the Jupyter using Homebrew in zsh shell
If you don't Python install 3.3or higher.
Open terminal
Using Homewbrew install jupyter
brew install jupyter
Now, you start a notebook
jupyter notebook

how can I get my Python 3.6 back after installing Tornado 4.5.3?

I use miniconda to run Python 3.6. Everything was fine until I couldn't start Jupyter notebook. The error message was:
File "/Users/usr/miniconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/usr/miniconda3/lib/python2.7/site-packages/notebook/notebookapp.py", line 45, in <module>
ioloop.install()
File "/Users/usr/miniconda3/lib/python2.7/site-packages/zmq/eventloop/ioloop.py", line 210, in install
assert (not ioloop.IOLoop.initialized()) or \
AttributeError: type object 'IOLoop' has no attribute 'initialized'
After a Google search, I tried the following:
conda install tornado=4.5.3
But it gave a warning message:
CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_digest as soon as possible.
But I didn't read carefully so I performed it anyway. Now I can open Jupyter notebook, but my Python was downgraded to 2.7 How can I get my Python 3.6 back?! :'(
Thank you in advance!
I solved the issue. Thanks to #C.Nivs and #Feelsbadman. Here is my solution:
I checked my python environment by: conda env list and found out I have a base, a 2.7 and a 3.6 environments existed at the same time, with the base being the default.
I activated my 3.6 env by source activate py36
I created an ipython kernel by conda install notebook ipykernel then ipython kernel install --user
Open jupyter notebook, now there is a Python 2 and Python 3 kernel.
I will try to remove the Python 2 from jupyter notebook since I don't use 2.
Thank you for the help.

A module is working in Anaconda prompt, but not in Spyder

I have been fighting with this problem for hours now, and it's a kind of complicated one.
I'm on windows 7, Python 2.7, Spyder 3.2.6
I tried to install OSMNX through cygwin, however I faced many issues. Finally managed to install it through windows cmd.
Through the anaconda prompt, I could import the osmnx with no error.
However, I'm trying to import it in spyder, but I keep receiving:
Traceback (most recent call last):
File "<ipython-input-2-2b99ab66aebb>", line 1, in <module>
import osmnx
ImportError: No module named osmnx
What is exactly wrong here? and how can I solve it?
The problem is the use of different environments for your anaconda prompt and your instance of spyder, as mentioned by #Simon. This problem and the different available solutions are reviewed here: GitHub discussion
You can solve the problem as follows. Provided that you have the package spyder-kernels already installed in your Anaconda prompt environment, run the following command in Anaconda prompt:
python -c "import sys; print(sys.executable)"
and copy the path returned to your console. Then, in Spyder go to Tools>Preferences>Python interpreter. Here you will see two options under Select the Python interpreter for all Spyder consoles. Check the second option and paste the path you copied from the Anaconda prompt. Close Spyder and open it again and now the import module command should work.
By doing this, Spyder will basically use the Python interpreter from the environment in which you have installed the new modules.
You need to sync the environment variables/path for both .
Just go to the anaconda promt and enter the command
> conda install spyder
It will automatically prepare the environment. Following that, just open up spyder and execute your code.
I have faced the same problem. I have installed the Spyder and Jupyter inside the conda environment. After that it's working fine for me.
source activate my_conda_env
conda install spyder
conda install jupyter notebook

Categories

Resources