holzschu / Carnets

Carnets is a stand-alone Jupyter notebook server and client. Edit your notebooks on the go, even where there is no network.
https://holzschu.github.io/Carnets_Jupyter/
BSD 3-Clause "New" or "Revised" License
567 stars 33 forks source link

importing from python file within same directory as the ipynb #140

Open eklektek opened 3 years ago

eklektek commented 3 years ago

I have a python file within the same directory as my .ipynb file. The file is called “car_data.py” it simply contains two array bmws and priuses, of tuples. I am able to import this file using the Mac version of Jupiter notebook.

Thus:

"from car_data import bmws, priuses"

However within Carnets - I get the error “ModuleNotFoundError”

Interestingly the first time Carnet loads my .ipynb file the error doesn’t occur and everything runs fine, however subsequent runs fail. So there must be some change to the search path that is used the first time a .ipynb file is run?

I have tried the standard approaching of importing ‘sys’ and appending the current directory, however this hasn’t work. Also moving the “car_data.py” to a subdirectory containing an init.py however this hasn’t worked either

I am using iPadOS 14.2 on a 6th generation iPad

Any suggestions/wisdom would be gratefully received.

holzschu commented 3 years ago

Hi, could you attach the files (.ipynb and .py)? I'd like to take a look.

eklektek commented 3 years ago

Attached is a zip of the two files, where import_error.ipynb attempts to import bmws, priuses from car_data_reduced.py and this results in ModuleNotFoundError

Works fine in the desktop version of jupyter notebook import_error.zip Thanks for taking a look.