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
Related
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.
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
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:
I have several packages being imported perfectly in my Python 3.5. But not in my Jupyter Notebook... When i try to Import those packages in Jupyter i get and error of module not found.
Is there a way to make Jupyter load my Python 3.5 as a kernel... or something similar. I'm working in a virtual environment. Already tried to reinstall the packages again in my virtual env But no success.
Try to install the packages inside a jupyter notebook cell like this:
!pip install package
So you are sure that the packages are installed in jupyter's environment
If you install the ipython kernel form inside the virtualenv, you can guarantee that the packages are imported to the jupyter if they are imported to this env. Also, if you use this approach, you do not need to activate the virtualenv every time you run the jupyter, because jupyter does it automatically.
$ python -m venv projectname
$ source projectname/bin/activate
(venv) $ pip install ipykernel
(venv) $ ipython kernel install --user --name=projectname
(venv) $ pip install {package needed to install}
Source: Using jupyter notebooks with a virtual 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