jupyter labs stopped importing packages from virtual environment - jupyter-lab

I'm using Jupyter Labs with a virtual environment. It previously recognized the environment and correctly installed the packages. A few days ago, it stopped importing some of the packages, although neither the virtual environment nor the kernel was changed.
The packages are pandas and transformers, and I can check that they're installed by running conda list after the environment is activated. I'm getting the error "module not found" in Juypter.
I've tried the following but I still get the error:
Stopped the session from the command line and restarted Jupyter
Tried a different virtual environment
Tried switching to a kernel based on the new environment
Read the documentation from JuypterLabs on troubleshooting but there are no new files.
However, the packages will install when I run commands directly from the terminal instead of from Juypter. I used conda to install all the packages, and when I run the jupyter --paths command it appears that everything is in order.
I'm not sure what the error is that's causing this behavior, or how to fix it. I'm using a Mac. Thanks in advance.

Related

VSCode Jupiter notebook cannot resolve import for package installed in editable (-e) mode

I am using a Jupyter notebook running in VSCode to test some ideas for a work project and I am using a package that is in a private GitHub repo. I encountered certain conflicts with versions of jax and numpy and after some fiddling trying to fix the issues, I simply re-installed said package to make sure I was using the correct versions of all required packages. Everything seemed fine until I re-opened the notebook and found a bunch of Import "<package name>" could not be resolved Pylance.
The imports still work and the code runs, however, PyLance appears not to be "seeing" said package.
I am using a conda Python 3.8 environment and to re-install the package I ran
pip install -e . --force-reinstall
I have also tried un-installing and re-installing the package, as well as creating a brand new conda env, and then installing the package there. Neither of these options worked however and I was stuck with the same issue.
Upon inspection of what is in sys.path I saw a strange entry
'__editable__.<package_name>-<package_version>.finder.__path_hook__'
I know that a colleague (who does not have this issue) does not see anything similar and instead has the correct local path to the package.
I should also note that I have the Python extension enabled, which includes the Jupyter and Pylance extensions as well. I have tried re-installing those extensions as well and that did not solve the issue either.
Edit.
I will add that I only get this PyLance error in notebooks. If I open a regular Python file then all PyLance features appear to be working as expected.

How to have dedicated Jupyter notebook configuration files on one machine

I am running a Windows 10 machine, where I have a Python installation installed from one of the programs I am working with. This leads to dependencies of this program to specific versions of Python packages, including Jupyter and Jupyterlab, and I cannot update/upgrade them without breaking the functionality in the original program.
Hence, I decided to install a more recent version of Python in addition to the one I already have on my machine. That was also not the issue, and installing all the packages I was after went fine so far.
However, even though I installed nodejs and npm within the new version of Python, when attempting to install a widget in Jupyterlab, it still does not recognize the packages.
In addition, wen running jupyter-lab.exe --generate-config, I am getting asked, if I want to override the existing configuration file.
I have no intention to do so, but would like to be able to configure the different jupyter notebook environments separate from each other.
Is there a possibility to do so?

Jupyter not working in VSCode Virtual Envirronemnt

I am new to jupyter and right from start I am trying to run it in VSCode and that too with a virtual environment. I hope that is not too much for you guys.
So here are steps I did;
I installed python and vscode
Added Paths in windows and all virtual environment things work fine
For data processing I created new virtual environment 'DataProcessingVenv'
I opened this venv in Terminal in VSCode and installed Pandas
I did pip install Jupyter
I did pip install ipykernel
next did ipython kernel install --user --name=DataProcessingVenv
In VSCode I created new notebook
pressed Ctrl+Shift+P and selected interpreter as /DataProcessingVenv/Scripts/Python.exe
Now I am trying to read a csv present in same fodler where notebook is present but somehow it is not working. I really don't know what is wrong and where, even don't know if I have provided all required info to solve the issue. Please guide me it some more info is required or if I can do something to solve the issue. I am attaching the current image in VSCode with error at the end.
So at the end the solution was simple. But it took time to learn. I just had to run all previous cells in Jupyter to make the current cell work.

Anaconda environment creation

I am new to python and machine learning. I am trying to create separate anaconda environments for tensorflow, keras, etc. in my Windows machine. I have successfully installed anaconda with automatic environment path setup. Created a test environment but when I try to create another one I get the following error. I have python 3.6.2 and 3.7.2 installed in conda. When I write the command
conda create -n t_tensor
it gives the following error. Not sure where the problem is. Any help is appreciated.
Thank you.
Error Image

Anaconda only comes with anaconda prompt

I used to have the whole anaconda package on my Windows 10 computer (an HP Envy) until recently, Windows 10 updated and the update caused problems so I restored the previous version of windows (keep in mind, I installed Anaconda about 3 updates ago so restoring should not have caused a problem). A few days later, I tried to use Jupyter but "jupyter notebook" no longer launched Jupyter when typed into PowerShell. I tried uninstalling and reinstalling with all different preferences (i.e. me only, all users, PATH, no PATH, etc.) but it still installs as only the anaconda prompt. When I type conda --version in PowerShell, my error says "The term conda is not recognized" ...
Does anyone have any suggestions? I really need to use Jupyter. Thanks!

Resources