0

I've recently moved the location of my git repo. All my standard Python scripts work just fine but for some reason my Jupyter notebooks can't even import any modules. I've re-cloned my repo to the original location and the notebooks run fine again.

I've tried searching the VS Code settings for something that resembles a working directory for Jupyter but no luck. Any ideas on what might be going on and how I could fix it?

For reference:

  • OS: Windows 10
  • VS Code: 1.53.2
  • Python extension: 2021.1.502429796
  • Jupyter extension: 2020.12.414227025

Edit:

I've been able to put a sticking plaster on this by using os.chdir() to select the new repo.

Jossy
  • 589
  • 2
  • 12
  • 36
  • Do you have a virtual environment? (this definitely doesn't contain a [example], as far as I can see) – user202729 Feb 12 '21 at 13:28
  • Afraid I've got no idea how to produce an MRE for this sort of thing. What should I include? – Jossy Feb 12 '21 at 14:19
  • Something like "create a git repo with `mkdir A; cd A; git init`, create a jupyter notebook in A, `cd A; mkvenv X`, execute `mv A B`, open the jupyter notebook, etc.) – user202729 Feb 12 '21 at 14:41
  • Although if you do have a virtual environment then that's obviously the problem. https://stackoverflow.com/questions/27186207/are-python-3-x-venv-environments-relocatable – user202729 Feb 12 '21 at 14:41
  • Thanks. Does a virtual environment control the working directory? Not sure this can be the issue as my normal Python scripts run fine from the same virtual environment as the one Jupyter is using. – Jossy Feb 12 '21 at 15:12
  • Can't tell without a [example]. – user202729 Feb 12 '21 at 15:31

0 Answers0