Jupyter notebook open from cmd at any location or any drive - python-3.x

Recently I uninstalled Python and Anaconda. And again reinstalled it. But now I am facing an issue. Previously I was able to open jupyter notebook at any location in any drive by opening Command prompt by typing cmd in the address bar but it's now showing the following error:
> Fatal error in launcher: Unable to create process using '"C:\Python310\python.exe" "C:\Python310\Scripts\jupyter.exe" notebook': The system cannot find the file specified.
How should I handle this now? Please help. I want Jupyter notebook to be open at a specific folder location in a specific drive by opening command prompt through address bar. But not working now.

Your issue is probably related to your Windows environment variables.
To get to the interface, type the following into a terminal window with admin privileges:
rundll32 sysdm.cpl,EditEnvironmentVariables
Under 'Path' make sure that your python installation folder is present, if not add it. For me, python is under 'C:\Anaconda' and jupyter under 'C:\Anaconda\Scripts', but that is for an Anaconda installation. For reference see https://docs.python.org/3/using/windows.html#setting-envvars.
To make sure that everything works, type:
> where python
> where jupyter
You should see the respective installation folders now.

Related

Cannot connect to ipykernel Python 3 in Jupyter anymore

I am trying to learn more in Python. However, the fundamentals in terms of the software itself are hard to grasp for me. Let's say things got messy: I could not access all imports easily - so I decided to uninstall all Python related software to start over:
Uninstall Python, Jupyter and Anaconda
Re-install Anaconda and Python.
Installed it in C://Users/Mark/Anaconda
Added Python as PATH
But now I can not access my ipykernels anymore. It can not connect once I want to open a script I made. It asks which kernel I want to start every time. Was not the case before. It tries to connect but then says: "Disconnected".
I tried to move the ipynb files to the new root folder and open them from Path but no luck.
I tried to use cd in the Anaconda Prompt to set the root folder to C://Users/Mark/Anaconda
What is holding me from working scripts again?
I tried to move the ipynb files to the new root folder and open them from Path but no luck.
I tried to use cd in the Anaconda Prompt to set the root folder to C://Users/Mark/Anaconda

Problem Loading Jupyter Notebook in Windows 10 Pro

I am new in Anaconda (Jupyter Notebbok) and training python. After I installed Anconda when I open Jupyter notebook, the program won't be loaded.
First I run 'jupyter notebook' from the 'command prompt':
Second, when InterneTExplorer loaded and then I click the New>Python3
Finally I expected to have 'jupyter notebook' to write python codes, but I see below picture:
Desired Page:
Can you help me to find the reason for the problem?
In the following link I have attached a video from my Desktop view.
https://www.youtube.com/watch?v=lDvYwHlvghI
Did you try to open the file from the terminal? Create an empty file. In terminal, go to that empty file directory and open that empty file from terminal in Jupyter notebook. Then try to create new .ipynb inside of that file. Just another way to test if it's browser issue or Anaconda download issue.
Command for terminal-
~cd file directory
~jupyter notebook
It will automatically open the Jupyter in your web browser from your terminal.
I copied the 'localhost' link from command prompt in the Firefox browser and solved the problem.

How to change Jupyter lab Working Directory

I'm using the latest version of Jupyter lab on a Windows 10 64 bit machine inside Firefox. When I start the Jupyter lab (via cmd) the default working directory appears to be
c:/windows/system32
(i.e the folder tab on the left) which is a terrible place to be meddling with, at leat for me. I don't know why Jupyter lab starts there. I've installed Jupyter lab using cmd with administrator privileges. Is that why? Should I have it installed just for a user? (My machine has only one user;me).
I tried changing the directory by using
jupyter notebook --generate-config
And inserted a path to my documents folder (in the path for kernels and notebooks line) , edited out the commentary ("#"). And when I restarted Jupyter lab nothing has changed. It shows the
c:/Windows/system32
as default directory which has so many windows folders and is too messy to deal with.
Any solutions will be greatly appreciated. Thanks in advance:)
A late answer to one of the most common Jupyter Notebook or Jupyter Lab questions most new users have about the file/folder structure when they first begin using Jupyter.
For those Windows users who may still be using that old school Windows Command Prompt - which is actually being phased out of Windows, the Windows Command Prompt will normally start-up and display the location where the Windows Command Prompt application is located on the Windows PC:
c:/Windows/system32
In a nutshell, the OP opened the Windows Command prompt, and then the OP typed the following code to start Jupyter Notebook:
Jupyter notebook
But when the OP created / saved the new Notebook file, it was saved to the Windows / system 32 folder - definitely not a location where anyone wants to save their files.
To avoid saving Jupyter Notebook files in the wrong place, the Command Prompt must be started in a different folder or be moved to another directory. One way to move the Command Prompt is by using an old dos command, Change Directory. Just type cd for Change Directory.
Best advice, create a new folder on the C drive and call it Jupyter_Files. Then use old dos, Change Director command, navigate from the location where the command prompt opens and move to that new folder. Do the following to navigate to the new folder.
cd..
cd..
cd Jupyter_Files
Now the Command Prompt is in the location where the Notebook files want to be saved. At the Command Prompt, type: Jupyter notebook. This will create and save those notebook files in this new folder.

JupyterLab installation with pip3

I installed JupyterLab with
pip3 install jupyterlab --user
Yet, when trying I try to launch it (jupyter lab), I get the following error:
Error executing Jupyter command 'lab': [Errno 2] No such file or directory
The JupyterLab installation guide on github says that: "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"
But I don't what that means, I greatly appreciate any help. I am using Ubuntu 18.04
As said by the guide itself you need to add the user-level bin directory to your PATH environment variable, in order to do so you need at first spot which is the bin folder where Jupyter lab has been installed, and after that you can add that path with a simple command:
export PATH=$PATH:/path/to/your/jupyterlab/bin/directory
and it's done. You can check if you added it by running this other command:
echo $PATH
And you should see the content of PATH variable.
This method though will just add that variable for the current shell, meaning that when you close the terminal you lose the change in the variable. In order to make it permanent you need to edit another file which is ~/.bashrc.
One thing though, it's really important that you just add this line to the file:
PATH=$PATH:/path/to/your/jupyterlab/bin/directory
without changing all the rest of the file if you don't know what you are doing.
To give you a recap on what to do to make it permanent open a new shell and type:
gedit ~/.bashrc
This will open the file where you need to add the "export PATH...etc" command right at the end of the file in a new line. Then save the changes and reboot, from now on you should be able to open Jupyter lab directly from a shell with the command:
Jupyter lab

Pycharm tensorflow ImportError but works fine with Terminal

I made a virtualenv with tensorflow installed and I changed Python interpreter set to the location where the virtualenv is located at. When I ran the program, it gives the error:
ImportError: libcudnn.so.5: cannot open shared object file: No such file or directory
I have the following lines written in my .bashrc file
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH
export PATH=${CUDA_HOME}/bin:${PATH}
Also, I found the libcudnn.so.5 file in the following path:
/usr/local/cuda-8.0/lib64
I encountered this error before I opened PyCharm and I did manage to install the correct cudnn version. The problem is, I can use
$ source [virtualenv_path]
to active the virtualenv and run python in terminal and everything works fine, no errors shown. The program also runs without error in Pycharm's terminal but it just gives me the above error whenever I click the run button. Could there still be something wrong with the environment variable? How do I fix it?
Unfortunately in pycharm you have to set CUDA_HOME and LD_LIBRARY_PATH inside the IDE. To do that go to the Run menu->edit configurations then choose your project. Then you click on the Environment Variables and add an entry for CUDA_HOME and LD_LIBRARY_PATH. When you have done that you can run directly from inside pycharm. I would also recommend setting the defaults to have these paths as well, so you don't have to do this for every project. Also it wouldn't hurt to make sure you have the interpreter from source [virtualenv_path] set while you are on this setting page. Let me know if you have trouble finding where to do this.
I've read this other Stackoverflow post: Pycharm environment different than command line, and it seems that the problem is that openning PyCharm in the normal way won't preserve the bash environment. The solution is to open PyCharm from the command line and everything works now. All you need to do is to open PyCharm using charm and everything works fine now.
I have searched a lot, but I didn't find the right solution for this question anywhere. I found the solution with my friends and I would like to share with you also.
If your Tensorflow works in terminal properly but doesn't work in Pycharm you have two solutions:
1- Open Pycharm from Terminal. For me:
pycharm-community
2- If you are using Unity, you need to edit .profile, because Pycharm doesn't preserve .bashrc: So, open a terminal and type:
gedit .profile
Then, add the following codes at the end of the opened file:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Save and exit. Now, you can work with Tensorflow in Pycharm without the necessity of opening the Pycharm form terminal.

Resources