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.
Related
Has anyone managed to run an ipynb Python notebook using a local kernel but connecting to a remote GitHub repository using the GitHub Repositories extenstion.
I can open the ipynb file directly from the GitHub repo but cannot connect to a kernel because it doesn't seem to find the local cached version of the notebook to run.
Error message:
[C 10:22:20.876 NotebookApp] Bad config encountered during initialization: No such notebook dir: ''/githubuser/reponame''
Using:
MacOS
VSC 1.66
GitHub Repositories extension v0.28.0
Tried multiple Python kernels.
Anyone got any ideas?
I am using windows, and it works well on my side. I think this extension works well with the local python environment.
The problem you have run across looks like the problem of jupyter configuration. You can execute jupyter --paths to get the jupyter configuration path. It should be “/Users/UserName/.jupyter/jupyter_notebook_config.py” on the MacOs. You can refer to here for the details of jupyter_notebook_config.py.
Then you need to modify c.NotebookApp.notebook_dir = to a existing path or just comment it.
I have a bit of a weird issue that I couldn't find an answer to on Google. I'm trying to use Python on VSCode (quite new to it, I've been using PyCharm till now), but for some reason when I try to import and use Numpy or PyTorch, it throws a ModuleNotFoundError (see below).
I've double checked to ensure I've selected the right environment and that Numpy and PyTorch are both installed in this specific environment.
This code also works without issue in this environment if I try it on PyCharm, so the issue seems to be entirely in VSCode alone. Note, I'm using the Code Runner extension by Jun Han to run this.
Please help! Thank you.
Thanks all for your suggestions. Reinstalling everything (Conda and VSCode, as well as PyTorch) fixed the issue for me.
The file is located on your desktop but the file should be somewhere where it has access to "python\Lib\site-packages" folder where numpy should be installed.
1.go to your folder where python is installed.
2.go to the folder called "scripts" and make a .py file in there, try to run the same code and if the "ModuleNotFoundError" isn't fixed yet.
3.reinstall numpy from the terminal in the file thats located in the scripts folder. I had the same issue but putting my file into the "scripts" folder fixed it for me.
If this dosent work just tell me. :^)
import graphviz works in jupyter notebook, but the same code does not work in Pycharm. I tried to setup an anaconda environment which includes graphviz and I am using that particular python interpreter from pycharm. I am stuck with this problems for last 24 hours, please help..?
Try creating a new project, than choose "Previously configured interpreter". Check if the Python exe within the correct enviroment is selected. So in "Users/UserName/anaconda3/envs/Python/python.exe". Than when the new project is created you can check in the terminal if the correct env is enabled by looking for the term in the brackets. (Should by "Python" for you). Than try to import graphviz in the Python Console. If this works your file has a wrong configuration. Copy it in the new project and add the correct Configuration. Tried this and it works for me. Hope I could help and good luck.
I've replicated Slack's API demo in a text editor and the terminal, but just for fun, I wanted to do it again using Jupyter notebook. I used the same virtual environment so as to rule-out dependency issues and the code was the same (cloned from the master repo). But for some reason, I'm always getting ModuleNotFound errors when I try to run the code in Jupyter cells and import the necessary packages.
I even re-built a fresh virtual environment, and ran the demo at a terminal from within Jupyter, and running the scripts works fine. I just doesn't execute in the notebook environment.
I'm using the same kernel across my Python interpreters, and I always start my virtualenv session before launching the notebook.
Anyone have any ideas why this would be the case?
Well, DUH. It was just a matter of uninstalling/reinstalling the package in a fresh virtual environment (and I'm pretty sure the latter wasn't absolutely necessary).
Thanks to this comment on Github for the guidance.
I've updated scipy package in my environment from the terminal and started the Jupiter notebook.
In a cell I run
scipy.__version__
but that shows the previous version which doesn't have some properties I need. What can be the cause of the problem?
screenshot
There might be several versions of the package still installed on your machine.
Restart completely the Jupiter notebook (even your computer). Make sure the jupyter notebook is runned in the correct environment where you have updated the package if you are using for example anaconda.
Search for the package name a list all the folders in which is it present.