How To Change Executable Path For A Jupyter Notebook Mac ~UPD~
CLICK HERE >> https://bltlly.com/2t1Lfm
I'm trying to run the anaconda distribution of python libraries in a Jupyter Notebook, but when I run the notebook I keep getting ImportErrors because the python path is set to the default distribution from Mac OS X 10.11
I've tried setting PATH in my .bashrc and .bash_profile, and using the commands which python, which jupyter and such show anaconda paths but jupyter notebook is not using the anaconda paths. What could be the issue here?
For me, I installed Jupyter after creating an environment, but then was trying to run a module installed from the base env. I found by "jupyter kernelspec list" ( ), my kernel.json at C:\Users\username\Anaconda37\share\jupyter\kernels\python3\kernel.json was pointing to the python.exe in my working env. Changed the path and solved it.
For old Jupyter Notebook interface installed with notebook package and run as jupyter notebook (see the next section for the identical interface installed with nbclassic and run with jupyter nbclassic, and for JupyterLab):
Find this folder on your C: drive, and in this folder, find the python file jupyter_notebook_config.py. Drag the file into a Notepad ++ to edit it.When editing, look around line 214, for the string that looks like:
Then save the file. Then open anaconda prompt again, type jupyter notebook. This should launch Jupyter Notebook in the browser in the folder with the above address. Here, the key point is to UNCOMMENT (which means to delete) the # at front of the line, and then, USE \\ double slashes (for the path separator) between folders. If you use only single slashes \, it won't work.
The shortcut for the jupyter notebook (be it from the start menu, a desktop shortcut or pinned to the taskbar) calls a number of Scripts (presumably to initialize the jupyter notebook etc.), which are written in the Target text field from the shortcut's Properties window.Appending
In case of using the Anaconda navigator to launch Jupyter notebook application, the way to configure is to un-comment the "c.NotebookApp.notebook_dir" field in "jupyter_notebook_config.py" and add the path. After updating the field looks like:c.NotebookApp.notebook_dir =
If you examine the command in the target box of this shortcut, you will notice that Notebook app is started by executing the file "C:\Users\\Anaconda3\Scripts\ jupyter-notebook-script.py" which accepts a path parameter.
The basic approach to define the location where the notebook files will be saved is --> to provide the path of the required folder when starting the Jupyter Notebook application. This can be done in two ways:
b. For target, at the end of the existing path, i.e, after sript.py", add this after a space. Some people have mentioned removing %USERPROFILE% from target. I did not come across this.Image for jupyter properties
Alternatively, you can also use it to create a dedicated shortcut using program C:/windows/System32/cmd.exe and arguments /k jupyter notebook --notebook-dir="%FOLDERPATH%" but this opens the notebook in the parent folder so you have to click down.
In case you are using WinPython and not anaconda then you need to navigate to the directory where you installed the WinPython for e.g. C:\WPy-3670\settings\.jupyter\jupyter_notebook_config.py
Note that this will override whatever path you might have set in a jupyter_notebook_config.py file. (Where you can set a variable c.NotebookApp.notebook_dir that will be your default startup location.)
If jupyter notebook is not in your PATH you just need to add the full directory reference in front of the command. If that doesn't work please try working from the earlier version. Very conveniently, now "Start in:" can be empty in my tests with 4.1.1 and later. Perhaps they read this entry on SO and liked it, so long upvotes, nobody needs this anymore :)
This might help someone who doesn't want to change config file. If you are on Windows/ using Anaconda3, go to Win Start ->Search for Jupyter Notebook(env).Click on it and the Jupyter opens up. On Jupyter webpage, on right hand side go to New -> Terminal and the terminal window opens up. In this terminal windows change the directory to the working directory, using cd command. Example: cd "c:\User\\workingdir". Now in the same terminal window type Jupyter-notebook, this will open Jupyter with the working directory we used in cd command above.
Step-2 : It has now generated a file in your .jupyter folder. For me, it's C:\Users\Admin.jupyter . There you will find a file called jupyter_notebook_config.py .Right click and edit it. Add the following line and set path of your working directory.Set your own working directory in place of "I:\STUDY\Y2-Trimester-1\Modern Data Science"
When you're using the terminal and type a command like python, jupyter, ipython, pip, conda, etc., your operating system contains a well-defined mechanism to find the executable file the name refers to.
(Parenthetical note: why is the first entry of $PATH repeated twice here? Because every time you launch jupyter notebook, Jupyter prepends the location of the jupyter executable to the beginning of the $PATH. In this case, the location was already at the beginning of the path, and the result is that the entry is duplicated. Duplicate entries add clutter, but cause no harm).
The full details here are not particularly important, but it is important to emphasize that each Python executable has its own distinct paths, and unless you modify sys.path (which should only be done with great care) you cannot import packages installed in a different Python environment.
The root of the issue is this: the shell environment is determined when the Jupyter notebook is launched, while the Python executable is determined by the kernel, and the two do not necessarily match.In other words, there is no guarantee that the python, pip, and conda in your $PATH will be compatible with the python executable used by the notebook.
So, in summary, the reason that installation of packages in the Jupyter notebook is fraught with difficulty is fundamentally that Jupyter's shell environment and Python kernel are mismatched, and that means that you have to do more than simply pip install or conda install to make things work.The exception is the special case where you run jupyter notebook from the same Python environment to which your kernel points; in that case the simple installation approach should work.
There is one tricky issue here: this approach will fail if your myenv environment does not have the ipykernel package installed, and probably also requires it to have a jupyter version compatible with that used to launch the notebook. So it's not a full solution to the problem by any means, but if Python kernels could be designed to do this sort of shell initialization by default, it would be far less confusing to users: !pip install and !conda install would simply work.
One source of installation confusion, even outside of Jupyter, is the fact that, depending on the nature of your system's aliases and $PATH variable, pip and python might point to different paths.In this case pip install will install packages to a path inaccessible to the python executable.For this reason, it is safer to use python -m pip install, which explicitly specifies the desired Python version (explicit is better than implicit, after all).
This is one reason that pip install no longer appears in Python's docs, and experienced Python educators like David Beazley never teach bare pip.CPython developer Nick Coghlan has even indicated that the pip executable may someday be deprecated in favor of python -m pip.Even though it's more verbose, I think forcing users to be explicit would be a useful change, particularly as the use of virtualenvs and conda envs becomes more common.
Even if the above changes to the stack are not possible or desirable, we could simplify the user experience somewhat by introducing %pip and %conda magic functions within the Jupyter notebook that detect the current kernel and make certain packages are installed in the correct location.
After proposing some simple solutions that can be used today, I went into a detailed explanation of why these solutions are necessary: it comes down to the fact that in Jupyter, the kernel is disconnected from the shell.The kernel environment can be changed at runtime, while the shell environment is determined when the notebook is launched.The fact that a full explanation took so many words and touched so many concepts, I think, indicates a real usability issue for the Jupyter ecosystem, and so I proposed a few possible avenues that the community might adopt to try to streamline the experience for users.
You can then either enter the full path of the Python interpreter directly in the text box (for example, ".venv/Scripts/python.exe"), or you can select the Find... button and browse your file system to find the python executable you wish to select.
Comment the if/else part and hardcode the path of your graphviz installation directory, inside which should be the executables (dot.exe, circo.exe, gvedit.exe, etc.). The new code has to look like this:
JupyterLab automatically checks to see if it needs to rebuild on startup. Insome cases, such as automated testing, you may wish to disable the startuprebuild checks altogether. This can be achieved through setting buildCheckand buildAvailable in jupyter_notebook_config.json (or .pyequivalent) in any of the config locations returned by jupyter--paths.
For each config path listed in jupyter --paths, the /labconfig directory contains configuration data. This configuration data from all of these directories is combined into a single configuration, with priority order given by jupyter --paths.
By default, the application directory is at/share/jupyter/lab, where is thesite-specific directory prefix of the current Python environment. You canquery the current application path by running jupyter lab path. Theapplication directory can be overridden using the --app-dir command-lineoption in any of the JupyterLab commands, or by setting the JUPYTERLAB_DIRenvironment variable. 2b1af7f3a8