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
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'm pretty new to python, Jupyter notebook, Tensorflow, and that whole lot in general. I'm getting started with a machine learning project. I've gotten to the point where I want to import "nltk" into my thing. It doesn't work. I've installed nltk with pip, and conda, and everything, in my terminal. When I do it again in the notebook, it says I've already installed it, which is correct. But when I try to import it it gives me a ModuleNotFoundError:
I'm on a macbook, by the way. Any help?
Going forward you can follow these steps (through terminal) so that same issues don't crop up again.
Create a conda environment if it's not already done
conda create -n py3_env python=3.8
Get into the conda environment
conda activate py3_env
Install ipykernel
conda install ipykernel
Link the kernel to this conda env
ipython kernel install --user --name=py3_env
Deactivate the conda environment
conda deactivate
Now, when you open jupyter, you can select this kernel from the dropdown menu kernel >> Change kernel. Now, all the packages you've installed in this conda environment would be available in jupyter as well. E.g. you can install nltk in this environment in the following way:
conda activate py3_env
pip install nltk
conda deactivate
i'm created a conda environment
conda create -n tfgpu tensorflow-gpu
conda activate tfgpu
but now after running
(tfgpu) > jupyter notebook
I can't import tensoflow as tf, notebook doesn't load this environment!
Why it's happen?
My problem is solved after:
https://stackoverflow.com/a/44786736/12370909
conda create -n tfgpu tensorflow-gpu
conda activate tfgpu
python -m ipykernel install --user --name tfgpu --display-name "Python (tfgpu)"
jupyter notebook
Then you could be able to create a new Notebook using your environment by selecting "Python (tfgpu)" from the drop-down list.
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
I've created a python 3.6 environment using the conda command. I have then activated that environment and installed a few librairies.
I then open a Jupyter Notebook in this environment using Anaconda Navigator and I am unable of importing graphviz, a librairie I have installed.
The name of the kernel on the top right is Python 3 and not the name of my environment.
How can I install librairies in my environment and then import them in Jupyter Notebook?
Thank you for any help
Code I ran to create my environment and install the librairies:
conda create -n myEnv pip python=3.6
activate myEnv
conda install -c conda-forge opencv
conda install -c conda-forge matplotlib