opening jupyter notebook in anaconda - jupyter

When I tried to install Anaconda into my computer, the destination folder for my installation was "C:\Users\Lara Nguyen\Anaconda3". When I clicked "Next", there was a pop-up saying that "Error:'Destination folder' contains 1 space. This can cause problems with several Conda packages, and is thus disabled. Please install to a path without a space". After the installation, opened cmd and typed "Jupyter Notebook" but there was an error message saying that:"jupyter"is not recognised as an internal or external command, operable command or batch file.
Is there anyway I can fix this problem?

Looking at your path I am assuming you are using windows (I mention this so that other linux user do not refer this answer)
First of all it's clearly mentioned in the Anaconda installation documents that it is recommended to install to a path which does not have spaces
If you installed it correctly, did you register the anaconda path to the environment variable? If not then do that
The paths that you have to register will be something like this:
C:User\username\Anaconda3
C:User\username\Anaconda3\Scripts
C:User\username\Anaconda3\Library
Now run the anaconda prompt (not cmd) and just type the conda commmand
After typing the conda command if you did not get any error then you have successfully installed jupyter as well (You can cross check this by going to following location : C:User\username\Anaconda3\Scripts and searching for jupyter-script.py file)
now in anaconda prompt itself run the command jupyter notebook
if it still throws you error then I would strongly recommend you to reinstall Anaconda3 and follow the above steps correctly

Related

"Running cells requires Jupyter notebooks to be installed" error in VS Code

I'm trying to use the new Jupyter integration for the Python extension in VS Code, and I'm getting the above error even though I have Jupyter installed and it works fine from the command prompt.
Here's my environment:
Python extension version 2018.10.1, and I see Run Cell/Run All Cells tooltips above #%% comments.
I've used the Python: Select Interpreter command to select my Anaconda environment, which is at ~/AppData/Local/Continuum/anaconda3/python.exe.
I have Jupyter installed in that interpreter (jupyter.exe is in the Scripts sub-folder under that location), and it runs fine with the jupyter notebook command at the Anaconda prompt.
But whenever I click on Run Cell or press shift-enter, I get this error message:
"Running cells requires Jupyter notebooks to be installed." Source: Python (Extension)
Is there something else I need to do to configure this?
You may give one try by restarting VS Code in following mentioned way [ It worked for me. ]
Open Bash or any other cmd
Activate any conda environment [ See below command ]
source activate base [ means activate base environment ]
Run VS Code instance [ See below command ]
code .
Now when you'll click on Run Cell or press shift-enter, it should work.
The problem is an issue in the VS Code python extension itself. There are a number of issues related to this open in the repository: #3354, #3343, #3330, and the issues are being worked on, see #3374.
The reason, as far as I understand, is that in this case - and in some other cases - the anaconda environment is not activated before running the command. Situations where the environment is activated are e.g. opening a python terminal or running a file in the python terminal, but this also needs to happen for Jupyter, Tests, and so on.
While theoretically, adding the Scripts folder to your PATH, as David mentioned, could help, it did not help in my case. This may just not be enough to properly reflect what happens on activation.
My guess is that we will have to wait for this issue to be resolved in the repo, but if someone else finds a workaround, I'd be happy.
Simply running vscode from the activated environment did not work for me, here is what did:
In terminal (bash) I ran:
conda activate <environment-name>
conda install jupyter notebook
When the install finishes, open vscode from terminal (the same shell with activated environment) with the command:
code .
Notes:
Replace '.' with the path to the directory you want to open if it's not the current directory.
I've written 'conda install ...' but mamba also works.
If the terminal command for 'code ' does not work, it's likely you need to add it to environemnt variables; in such a case, this post might help.

Windows - 'jupyter' is not recognized as an internal or external command, operable program or batch file

I'm on Windows command line.
I installed Jupyter via pip 3.
I got this error, I suspect its path.
'jupyter' is not recognized as an internal or external command,
operable program or batch file.
However when I run
where jupyter
It returns:
INFO: Could not find files for the given pattern(s).
Does this mean Jupyter hasn't downloaded properly? Because it seemed to be fine when using the pip3 command.
Use the command py -m notebook and the problem is sloved.
When you are installing Anaconda ensure to check the check boxes to add the path to env. This worked for me.
It could have two reasons:
Either Anaconda is not installed in Windows.
Install it.
Path for Anaconda is not set in Environment variable.
Open Anaconda Command Prompt, search for "where conda".
Results:
C:\Users\<loremipsm>\AppData\Local\Continuum\anaconda2\Library\bin\conda.bat
C:\Users\<loremipsum>\AppData\Local\Continuum\anaconda2\Scripts\conda.exe
Use : Path as "C:\Users\<loremipsum>\AppData\Local\Continuum\anaconda2\Scripts"
**Path is a sample one, use you own.
I'm also new to Python, but this is what I found.
Try installing using Anaconda, check Add Anaconda to my PATH environment variable.
The reason is because if it's not checked, or if you use pip 3, paths are not automatically added.
You may also choose to manually add the path in Setting - Environment Variables.
You need to add path,where Anaconda is installed,in the Environment variable.
In my case it's
C:\Users\zahid\AppData\Local\Continuum\anaconda3\Library\bin
C:\Users\zahid\AppData\Local\Continuum\anaconda3\Scripts
Even I was stucked with the same issue.
What I did was I searched for the jupyter path in the Anaconda Prompt using the command "where jupyter"
After that I got a path
Then I went to my Environment variables(you would get this thing when you would search for the same) and then specified the new path there.
And the problem was solved.
Go to start and search for Anaconda Navigator
Launch the program
Then in Home section you will see Jupyter Notebook then click on Launch
Hope this helps

Changing Jupyter Notebook start location [Win 7 Enterprise]

I am trying to change the default Jupyter Notebook start directory on my Windows 7 Enterprise machine. Other answers have suggested changing the "Start In" field found through Right-click>Properties>Shortcut on the Jupyter program in my Start menu, however this doesn't have any effect. When I change this field to my desired directory and try running the program it still opens in the default directory, when I recheck the "Start In" field it is the same as whatever I had changed it to so it looks like it isn't being changed back by Windows, rather it's being disregarded entirely. For reference the default directory is at P:\ which is not a local directory and is hosted on my company servers, and I am trying to change the Jupyter startup directory to C:.
I'm sure the path is correct - I've tried a few different ones and they are working with autocomplete. I should mention this is a locked down corporate machine and I have to run Jupyter as administrator or else it exits immediately. I do have elevated rights and have checked the user permissions on Jupyter. This is using the Jupyter that comes as default with the current Python 3.5 distribution of Anaconda - I have also tried reinstalling the whole Anaconda package and I'm currently working with a fresh default install.
I am wondering if there is perhaps a way through changing the startup script that is run when you execute the program?
Found the solution - go to your Anaconda install directory (for me this was C:\Anaconda3) and open the file cwp.py in a text editor. Change the line
os.chdir(documents_folder)
to
os.chdir("C:\\my\\path\\here").

How to set a default environment for Anaconda / Jupyter?

I have installed Anaconda for my Machine Learning course. I'm using it as IPython (Jupyter) notebook, in which we have lessons. OS is Ubuntu 14.04 LTS. Basically, I always run it from Terminal with:
jupyter notebook
I have created new environment called su_env from root environment (exact copy) with one package added. Now, I'm wondering: how can I set environment su_env as default one? I have dozen of notebooks so it's annoying to set up each time for every notebook the environment, in "web" GUI of Jupyter.
EDIT: I'm interested in a solution where you don't have to set environment before running notebook. My logic is that, somehow, automagically, jupyter sets root environment on its own while starting up. Because of that, I'm wondering is it possible to set some config file or something so jupyter sets su_env instead of root. Also, if you know that's not possible (and why), I would like to know that.
First activate the conda environment from the command line, then launch the notebook server.
For example:
$ source activate env_name
$ jupyter notebook
Note: This might only work with environments that were created from within Jupyter Notebook, not environments that were created using conda create on the command line.
In your ~/.bashrc, include the line:
alias jupyter="source activate su_env; jupyter"
This will condense the two commands into one, and you will activate su env whenever you call jupyter notebook or lab or whatever
Edit your bashrc and add source activate su_env then that env will always be active. To switch back to to root (or any other env) source activate env_name
You can use this on conda prompt:
conda activate env_name
jupyter notebook
source activate env_name gives me an error: 'source' is not recognized as an internal or external command, operable program, or batch file.

Can not create a "notebook" using ipython Notebook

I have recently installed ipython using Enthought's EPD python install - and when starting the iPython HTML notebook from the command prompt by typing:
ipython notebook --pylab=inline
I manage to get the localhost browser notebook screen pop up correctly.
However when I try to create a new notebook by clicking "New Notebook" I get the following error message:
"Creating Notebook Failed The error was: Unexpected error while autosaving notebook: C:\Windows\System32\Untitled0.ipynb [Errno 17] No usable temporary file name found"
I am assuming this i sbecause I may not have write privilege for that particular drive. So I have tried to go into the "ipython_notebook_config.py" file and change the following:
# The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = u'C:\Users\Stuart\Documents\iPython'
and
c.FileNotebookManager.notebook_dir = u'C:\Users\Stuart\Documents\iPython'
I have then closed down all the cmd windows and started the ipython notebook agaion. But when I click on "New Notebook" I get the same error message as before:
"Creating Notebook Failed The error was: Unexpected error while autosaving notebook: C:\Windows\System32\Untitled0.ipynb [Errno 17] No usable temporary file name found"
Could someone please help me as to how I can get this working? Any help very much appreciated.
The answer kindly provided by #Jakob in the comments above did the trick:
"Can you try switching to C:\Users\Stuart\Documents\iPython in the terminal before starting the notebook?"
Just change the directory where are run your iPython notebook. For make it, you right-click on the shortcut and edit properties. In this properties, a field named "run directory" or something like that. Put your link in this field.
I just experienced the same problem. I even erased all the untitled.ipynb files in the directory. Then I realized that I had other copies of Anaconda terminal open. When I closed them and tried again, things went back to normal.
If you run the IPython as administrator you won't run into error for starting a new notebook. To do that right click on the Ipython shortcut and click on run as administrator.
I also had the same problem, I was not able to create the new notebook or access existing notebook present in that directory.
Error Message - Unexpected error while saving file:/path/ database is locked
Turns out my old anaconda jupyter notebook terminals were open and running in the background. Every time I started jupyter notebook I used the new instance that led me to this problem. When I closed all terminals and restarted new Jupyter notebook terminal it started working again.
Many of the problems with Anaconda/Jupyter/Notebooks can be solved by examining and cleaning up what you have in your environmental variables such as Path or, if you trying to set up files to store Notebooks that you develop.
There is a very good discussion of environmental variables here:
http://johnatten.com/2014/12/07/adding-and-editing-path-environment-variables-in-windows/
It is obvious that if Anaconda/Jupyter/Notebook can't find the files they can't run them.
At a minimum your path in environmental variables should contain:
c:\users\*******\Anaconda3 where ******** is your user name
c:\users\*******\Anaconda3\Scripts
then you could create environmental variables that point to your personal Notebook code directories: (note: there can't be any spaces in the addresses) in Windows Environmental Variables (System Properties --> Environmental Variables --> add to User and System variables
variable value
NOTEBOOK address of your personal Notebook location
TESTING address of your Notebook Testing location
With this setup you can on the Anaconda Command
jupyter notebook %TESTING%
or
jupyter notebook %NOTEBOOK%
Another way you can go to your own Notebook directory is to change
jupyter_notebook_config.py
Go to:
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'your Notebook directory address goes here'
remove the ## and enter your directory using \'s instead of \ in the address
Then anytime you enter 'jupyter notebook' you will start at your Notebook Directory.