New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError while trying to import project modules #12976
Comments
Please could you enable logging as follows:
|
debug 23:20:14.223: VSCodeNotebookController::handleExecution, Class name = _v (started execution)
warn 23:20:16.043: StdErr from Kernel Process c:\Users\Babak\AppData\Local\Programs\Python\Python310\lib\site-packages\traitlets\traitlets.py:2196: FutureWarning: Supporting extra quotes around Unicode is deprecated in traitlets 5.0. Use 'hmac-sha256' instead of '"hmac-sha256"' – or use CUnicode. debug 23:20:16.134: KernelProcess output: NOTE: When using the To exit, you will have to explicitly quit this process, by either sending To read more about this, see ipython/ipython#2049 To connect another client to this kernel, use: debug 23:20:16.134: Kernel Output: To connect another client to this kernel, use: --existing c:\Users\Babak\AppData\Roaming\jupyter\runtime\kernel-v2-305126UHZHyUqnf2Y.json debug 23:20:16.154: Kernel Launcher. launch, Class name = vp, completed in 1925ms, has a truthy return value, Arg 1: {"id":".jvsc74a57bd083d208b031a4a5a0824f5f0b47c0388aa3b94cdd004c2f68e4341ab470ede466.c:\Users\Babak\AppData\Local\Programs\Python\Python310\python.exe.c:\Users\Babak\AppData\Local\Programs\Python\Python310\python.exe.-m#ipykernel_launcher","kernelSpec":{"interpreterPath":"c:\Users\Babak\AppData\Local\Programs\Python\Python310\python.exe","isRegisteredByVSC":"registeredByNewVersionOfExt","name":"pythonjvsc74a57bd083d208b031a4a5a0824f5f0b47c0388aa3b94cdd004c2f68e4341ab470ede466","argv":["python","-m","ipykernel_launcher","-f","{connection_file}"],"language":"python","executable":"python","display_name":"Python 3","metadata":{"interpreter":{"path":"c:\Users\Babak\AppData\Local\Programs\Python\Python310\python.exe"}},"env":{}},"interpreter":{"id":"C:\USERS\BABAK\APPDATA\LOCAL\PROGRAMS\PYTHON\PYTHON310\PYTHON.EXE","sysPrefix":"C:\Users\Babak\AppData\Local\Programs\Python\Python310","displayPath":{"$mid":1,"path":"/C:/Users/Babak/AppData/Local/Programs/Python/Python310/python.exe","scheme":"file"},"envName":"","displayName":"","envType":"Unknown","version":{"major":3,"minor":10,"patch":10,"raw":"3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)]"},"path":"c:\Users\Babak\AppData\Local\Programs\Python\Python310\python.exe"},"kind":"startUsingPythonInterpreter"}, Arg 2: 60000, Arg 3: "/y:/Programming/my-codespace/utils/my_script.ipynb", Arg 4: "y:\Programming\my-codespace\utils", Arg 5:
|
Please note that I did the above procedure on my local VS Code. Let me know if I should do the same thing or something else on the GitHub editor. |
Please could you upload all of the logs, the logs you uploaded are missing a lot of information. Please re-load vscode, and replicate the issue and then copy the logs |
Sorry for the misunderstanding. |
You need to create a .env file with the following value
Ideally you should be able to just add the following, however that does not work right now due to microsoft/vscode-python#20784
|
@DonJayamanne do you have any idea? |
@BabakAmini
What do you mean by GitHub workspace |
I've already set This is a summary of what I did until now: A- For VS Code on my local Windows machine:
B- For the GitHub codespace version I tried to do the same things as above:
I can confirm that |
@BabakAmini Lets focus on windows for now |
Setting the path to the project path didn't work for me. Instead, I had to do those two steps in section "A" I mentioned before - one for the Python scripts (.py files) and the other one for the Jupyter notebooks. |
Yes, that is the solution and that is expected. Now that we know local window works, lets move onto Code spaces, |
Closing this issue as its been over 4 weeks, since the information was requested. |
As I said before, for the GitHub codespace version I did the same procedure as the local version. Python files work as expected but Jupyter Notebooks fail. |
However thats in the terminal, and that doesn't apply, thats the same as running this outside vscode with the env variables configured for a terminal |
Applies To
What happened?
Recently I started using GitHub codespace for the first time. I created a new codespace from one of my repositories. Assuming the folder structure as below:
I get the following error when I import
config.py
insidemy_script.ipynb
:ModuleNotFoundError: No module named 'config'
Autocomplete is working inside the editor, and it recognizes
config.py
while I try to import itAfter a while red line appears indicating an error
All methods, classes, and variables belonging to
config.py
are available insidemy_script.ipynb
by autocomplete.Currently, I'm using PyCharm on my computer and have no issues with that repository but I get the same error when I do the same thing on my local VS Code. Also, I had the same issue in python script instead of Jupyter notebook which was resolved by adding the following line to the
settings.json
file in my Windows machine:"terminal.integrated.env.windows": {"PYTHONPATH": "${workspaceFolder}"}
and this to the Codespace version:
"terminal.integrated.env.linux": {"PYTHONPATH": "${workspaceFolder}"}
I would appreciate it if someone could help me in this regard.
VS Code Version
1.75.1
Jupyter Extension Version
2023.1.2010391206
Jupyter logs
Coding Language and Runtime Version
Python v3.10.10
Language Extension Version (if applicable)
No response
Anaconda Version (if applicable)
No response
Running Jupyter locally or remotely?
Local
The text was updated successfully, but these errors were encountered: