When I first started using notebooks, one of the letdowns was that I wasn’t able to navigate upwards out of the installation folder. I save all my projects on an extra internal hard disk drive, both for safety and portability. It’s also never a bad idea to have an additional backup (besides GitHub). Accessing these projects through my (Anaconda) Jupyter Notebooks seemed to be impossible. However, several solutions have been proposed on StackOverflow and other boards. Here’s a quick overview.
Throughout this blog post I’ll be using D:/python/foo as project folder. My Anaconda environment is data_science.
Solution 1: navigate to the folder and run Jupyter
The first solution is straightforward. You simply activate your environment, you browse to your project folder in the Anaconda Prompt, and you run Jupyter notebooks. It’s not a one-time solution. Every time you want to work on your project, you’ll have to retake these steps.
activate data_science d: cd python/foo jupyter notebook
Solution 2: set the notebook-dir parameter
A faster solution (just one line of code) is to set the notebook-dir parameter when starting Jupyter notebook.
jupyter notebook --notebook-dir=D:/python/foo
Solution 3: edit the configuration file
A more permanent solution is editing the Jupyter configuration file. By running the following command in your Anaconda prompt, a file will be created (jupyter_notebook_config.py in your Jupyter installation folder).
jupyter notebook --generate-config
In this file, you’ll find c.NotebookApp.notebook_dir after a hash. Uncomment the line by removing the hash and set the value to the directory of your projects.
c.NotebookApp.notebook_dir = 'D:\python'
Now run Jupyter Notebook from the Anaconda prompt (or the Navigator), and you’ll start from your preferred directory. Keep in mind that you’ve changed the directory for every environment.
Another nuisance solved!
“By running the following command ”
You forgot to add the command
Thanks, I updated it!
Thanks Roel this was really helpful and clear. Solution 3 was exactly what I was looking for.
Thanks Roel.
I’m using Debian 11 with Jupyter.
It worked fine. But when I create a new notebook in the new directory, there is an error message, looking for the old directory.
I wonder to know if there is another env-variable to change
Sincerely
Thank you very much!
I was looking for the ‘Solution 3’ given here and it worked perfectly fine.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
Thanks!
It worked 🙂 <3
Monitoruj telefon z dowolnego miejsca i zobacz, co dzieje się na telefonie docelowym. Będziesz mógł monitorować i przechowywać dzienniki połączeń, wiadomości, działania społecznościowe, obrazy, filmy, WhatsApp i więcej. Monitorowanie w czasie rzeczywistym telefonów, nie jest wymagana wiedza techniczna, nie jest wymagane rootowanie.
Your article helped me a lot, is there any more related content? Thanks! https://www.binance.com/sv/register?ref=V3MG69RO