Unable to start session for jupyter kernel python vscode - python

I have looked at other issues posted on stack overflow and github:
https://github.com/microsoft/vscode-jupyter/issues/728
Unable to start Jupyter notebook on VS Code
A lot of people could run this command:
python -m pip install 'traitlets==4.3.3' --force-reinstall
And this would resolve issues with the jupyter kernel not loading within vscode.
I consistently have issues connecting to the kernel and after a period of time I am presented with a message:
Unable to start session for kernel Python 3.7.4 64 bit ('name_of_virtual_environment'). Select another kernel to launch with.
I am using wsl 2 with ubuntu 20.04 LTS and I have selected the correct python interpreter (for the python extension and in the actual notebook). I am also using pyenv to create my virtual environments.
vscode version 1.52.1

It is recommended that you check whether the dependency package "ipykernel" required by Jupyter notebook has been successfully installed in your chosen python environment: ("pip show ipykernel")
Reference: Jupyter notebook in VS Code.

uninstall jupyter and its dependencies, then reinstall them.
pip uninstall jupyter
pip uninstall jupyter_core
pip uninstall jupyter-client
pip uninstall jupyter-console
pip uninstall jupyterlab_pygments
pip uninstall notebook
pip uninstall qtconsole
pip uninstall nbconvert
pip uninstall nbformat`
reinstall jupyter notebook and plugins
pip install jupyter
pip install jupyter_core
pip install jupyter-client
pip install jupyter-console
pip install jupyterlab_pygments
pip install notebook
pip install qtconsole
pip install nbconvert
pip install nbformat

Related

How to install Fiona for latest Python 3.9.6 to import geo pandas in Jupyter Notebook Python?

How can I install geo pandas in Jupyter Notebook?
I have the latest version of Python - 3.9.6 and I know that I need to download fiona or something like this but I have huge problem to do that because when I try: pip install geopandas I have an error.
I know that on stack there are many questions about that but on this page is Fiona only for python 3.7: https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona
Could you write me step by step how to install geopandas on Jupyter Notebook ?
Setting up geopandas is a bit tricky. There are lots of dependencies which some of them require building if you use pip.
The best and easiest solution I suggest is using Miniconda or Anaconda to install geopandas.
Just install Miniconda from: https://docs.conda.io/en/latest/miniconda.html
Then open miniconda prompt. In the command line create a new environment:
conda create --name gis python==3.9.6
After installation you need to activate your environment. The name of the enviroment as you can see in the command is gis:
conda activate gis
Then we need to install your packages:
conda install -c conda-forge geopandas jupyterlab
Using conda-forge gives you the latest version. This will install all required packages at ones. It will also install jupyter lab.
To run the jupyter lab at your directory run the Miniconda prompt and change the directory:
cd <path to your directory>
The activate your environment:
activate gis
And run jupyter lab:
jupyter lab
Then you should see the ipykernel start and jupyter lab will show up in your default browser. The home directory of jupyter will be the one you set.
Alternatives to Conda:
If you want to use pip only you can install pipwin so it will get the wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs/
Also you can download wheels from https://www.lfd.uci.edu/~gohlke/pythonlibs/ yourself and install the package by using this command in your active environment:
pip install <path to the downloaded wheel>
you can see all required packages from here:
https://geopandas.org/getting_started/install.html

How to completely uninstall anaconda and jupyter? Windows 10

My jupyter notebooks are no longer capable of saving files, so I need to completely uninstall all python, jupyter, and anaconda files so that it's like I never had them, but I can't figure out how. Uninstalling anaconda in control panel does not uninstall jupyter. Uninstalling it from anaconda navigator also does not work.
Completely uninstall jupyter:
pip install pip-autoremove
pip-autoremove jupyter -y
pip-autoremove jupyter-core -y
After that run
pip freeze | grep jupyter
and remove any packages with pip uninstall {package-name}.
If pip doesn't work try pip3.
Completely uninstall anaconda:
conda install anaconda-clean
anaconda-clean --yes
Then uninstall via control panel.
Turns out I was uninstalling successfully, but the problem was not Anaconda. The Windows Defender "Controlled Folder" protection was on.

Tensorflow Error: ModuleNotFoundError: No module named 'tensorflow_core.estimator'

Running on MacOS, Catalina.
Other Details:
Jupyter Notebook
!pip install --no-deps keras==2.2.4
!pip install --no-deps tensorflow==1.15.3
Python Version 3.7
Following virtually step-by-step from: https://machinelearningmastery.com/how-to-train-an-object-detection-model-with-keras/
Anyone encounter this error / know how to resolve?
Resolved by restarting Jupyter Notebook kernel. Consulted various resources online to install / uninstall packages and items, so difficult to pinpoint was produced the desired result -- but for those encountering this, ensure to restart kernel.
On Windows, in my Anaconda virtual environment running Python 3.7, I have fixed this issue by simply upgrading TensorFlow and Keras to the latest versions.
I did this by running the following PIP command in my Anaconda terminal:
pip install tensorflow --user --upgrade
pip install keras --user --upgrade

Python doesn't see packages with Jupyter Notebook

I use Jupyter Notebook with a virtual environment.
I have a dependency installed, but can't import it:
cell 1:
!pip3 install sent2vec
Requirement already satisfied: sent2vec in
venv/lib/python3.7/site-packages (0.0.0)
cell 2:
import sent2vec
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-06231d291a17> in <module>
----> 1 import sent2vec
ModuleNotFoundError: No module named 'sent2vec'
How this can happen? How to fix this?
> pip3 list
Package Version
------------ ---------
certifi 2019.9.11
chardet 3.0.4
Cython 0.29.14
idna 2.8
joblib 0.14.0
langdetect 1.0.7
nltk 3.4.4
numpy 1.17.1
pip 19.3.1
requests 2.22.0
scikit-learn 0.21.3
scipy 1.3.2
sent2vec 0.0.0
setuptools 41.6.0
six 1.13.0
urllib3 1.25.7
wheel 0.33.6
You'll note that jupyter is not listed in your installed packages. That means you're running it from a different virtual environment. As I mentioned in the comment responding to your question, you can run which jupyter to find out where your Jupyter Notebook application is being run from (assuming you're on a *NIX system); in this case, it won't be from the python3.7 virtual environment that shows up in your first code block.
To resolve the issue, you simply need to run pip3 install jupyter, then retry running jupyter notebook.
Alternatively, you can add your virtual environment as a kernel so that it can be selected when you're running Jupyter from your original environment. To do this, you would run (assuming pip is connected to your original environment):
pip install ipykernel
ipython kernel install --user --name=<insert name of your venv>
You should then be able to select that venv as a kernel on new notebooks. (Source for info on venv activation in Jupyter).
Try by installing directly within Jupyter using the following command:
import sys
!{sys.executable} -m pip install your_package_name
Run this (with envname your enviroment name):
jupyter kernelspec uninstall envname
ipython kernel install --user --name=envname
Sometimes Jupyter doesnt update properly the kernels associated with enviroments.
So the solution is to uninstall it and install it again.
I had the same problem and this fixed it
It apears that you need Numpy 1.17.1(you have Numpy 1.16.0) to use sent2vec
requirements https://github.com/epfml/sent2vec/blob/master/requirements.txt

Anaconda Navigator installing old version of Tensorflow

I've been trying to find a way to install Tensorflow v1.0.0 in anaconda but there is only v1.2.1 and v1.1.0 in the options.
I've tried to use pip to install wheel packages but resulted in 'could not find a version that satisfies the requirement' error.
Any suggestions on how I can install v1.0.0?
I'm not sure if this is relevant but I'm using windows 10 64 bit, no gpu, 8gb ram, and i3-2120
TensorFlow 1.0.0 for Windows is only compiled for Python 3.5. If you have a recent install of Anaconda (4.3.0 or higher), you are likely on Python 3.6. To get specifically 1.0.0 you need to the following Conda commands to create a Python 3.5 environment named "tensorflow" with Jupyter Notebooks, and then install TensorFlow 1.0.0
conda create --name tensorflow python=3.5 jupyter -y
conda install --name tensorflow tensorflow=1.0.0 --channel conda-forge -y
This is going to take a good amount of time to install. After it finishes, you can swap to the environment and fire up a Jupyter Notebook using:
activate tensorflow
jupyter notebook

Categories

Resources