Can't run jupyter notebook command in conda environment - python

I am getting this error when I try to run jupyter notebook after activating an environment. Should I install ipykernel in the environment? I have already installed nb_conda in base. I don't face this issue when running jupyter notebook normally.
I created the environment by running conda create -n env_name python=3.7.1 and then ran pip install -r requirements.txt. These are the requirements installed:

Related

Python New Env created by Anaconda Prompt not showing in Jupyter Notebook kernel list

I created a new python env using Anaconda Prompt by using the following steps:
conda create --name py3-TF2.0 python=3
conda activate py3-TF2.0
conda install tensorflow
pip install --upgrade tensorflow
pip install ipykernel
then i restarted anaconda and opened jupyter notebook.
The problem is when i open a new notebook and go to kernel to choose the new env i could not find the env i created (p3-TF2.0)
however, when I use conda info --envs, i find the new env created.
what is missing here?
thanks in advance
After activating the environment, try running:
python -m ipykernel install --user --name py3-TF2.0 --display-name "py3-TF2.0"
If this still isn't pointing to the correct environment (i.e. you can't import packages you know you installed in that environment), remove the py3-TF2.0 kernel that's broken with jupyter kernelspec remove py3-TF2.0.
Then run <your_path_to>/anaconda3/envs/py3-TF2.0/bin/python -m ipykernel install --user --name py3-TF2.0 --display-name "py3_TF2.0".
Additional help on Jupyter Kernels.

Conda install packages from jupyter notebook

I have used !{sys.executable} -m pip install to install packages i want to use in my jupyter notebooks.
Now i also want to install some packaged by conda and use in the same notebooks.
This is the command i run and the error message
They ask us to create a separate conda environment. I am confused about this.
Do we need to create a new conda enviroment everytime we need new packages?
What is the correct way to install and access conda packages on jupyter python notebook?
You shouldn't in principle install from the jupyter notebook but from the terminal/cmd.
You can create an enviroment >conda create --name myenv
And activate it: >conda activate myenv
now everything you install will be restricted to myenv. for example conda install numpy
To use the packages in myenv in jupyter simply open jupyter with your enviroment active:
>conda activate myenv
>jupyter notebook
Note that you have to install jupyter in your enviroment too: conda install jupyter

Using virtualenv on Jupyter Notebook

I trying to use virtualenv on jupyter notebook, to use all packages installed in an environment, but inside jupyter they are not recognized.
Already tried:
pip install tornado==4.5.3
pip install ipykernel==4.8.2
What I do is:
Initializing the environment on prompt (windows 7):
Move to directory of environment: cd C:\Python\Envs\env1\Scripts
and use: activate now the promt show (env1), so it's active.
From there, I move to another directory and call jupyter, but when starts, the package installed on envoriment are not callable.
How we can active the environment on jupyter?
Maybe you should install an ipykernel inside your venv first.
virtualenv .venv
.venv\Scripts\activate.bat to activate the venv.
pip install ipykernel
ipykernel install --user --name .venv to install a new kernel named .venv.
jupyter notebook here and you can select your new kernel.
REFERENCE: Kernels for different environments
for Max/Linux users:
python -m venv venv
source venv/bin/activate
pip install jupyter
ipython kernel install --user --name=venv
jupyter notebook

Jupyter Notebook's terminal command not using correct conda environment

I have 2 conda environments installed:
- env1: base environment where jupyter-notebook is installed and started from
- env2: project environment with ipykernel installed
I manually added kernelspecs for the 2 environments following this guide.
Everything works fine. sys.executable in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python), no matter which kernel I'm running in the environment defaults to env1.
Is there any way to have the notebook automatically change this to the kernel's environment?
P.S. I already tried installing nb_conda, nb_conda_kernels
install nb_conda and nb_conda_kernels into your base.
conda install nb_conda nb_conda_kernels -n env1
This should give you the ability to change kernel in jupyter, and use the env2 kernel.
I would install jupyter notebook in the base env (not env1, not env2)
Then install nb_conda_kernels in the base
in env1 and env2, install ipykernel
in env1 and env2, run this:
python -m ipykernel install --user --name env1 --display-name "env1 env"
Check this out for more info:
New Conda environment with latest Python Version for Jupyter Notebook

conda environment doesn't launch jupyter or recognize pip

I created a conda environment (with python 3.6 and Anaconda 3-5.2.0 on a Windows 10 machine) and activated it. I then installed both jupyter and pip using conda install jupyter and conda install pip. Both commands executed without problems.
When I type jupyter notebook or pip install [some package] I get this:
The same happens for the pip command. What might be the cause of this issue?

Categories

Resources