I installed TensorFlow and Keras using virtual environment as explained here and here.
Then inside the virtual environment I installed Jupyter notebook and executed this command to create a new kernel:
ipython kernel install --name "jupyter3_Python_3" --user
When I run jupyter-notebook from the console and change the kernel to jupyter3_Python_3 in Jupyter notebook, I get the following error:
It looks like keras in not installed.
However, when I run python from the virtual environment and do import keras, then everything works.
I assume that I incorrectly launch Jupyter notebook, therefore it does not get access to the virtual environment. But I followed all instructions. Any idea?
Try to first enter your virtual environment from the console:
source /var/venv/virtual_environment/bin/activate # or whatever your path is
and then run jupyter notebook
Related
I would like to use it with Jupyter Lab, a virtual environment created using virtualenv in the Terminal of my computer.
When I want to use the environment in the Terminal, I run workon ami, ami is the name of the environment and it works fine. I have installed some modules such as matplotlib, which I can use inside this environment.
I have tried to use this environment in Jupyter Lab. I have run
python -m ipykernel install --user --name=ami
The name ami can be selected as a kernel in the Jupyter Lab session, but the matplotlib module is not installed. It seems the ami environment created is not the same as that used in the Terminal.
I have tried to install Jupyter Lab in the ami environment, but it does not have matplotlib installed.
I would like to use the environment in Jupyter Lab without installing the Python modules that I already installed.
I'm trying to run a simple
!python script.py
command within a Jupyter notebook running on a custom kernel (virtual environment) where I installed a number of modules. When I run the above command, I am getting some errors related to missing modules, meaning it is not running that code on the same virtual environment as the jupyter notebook.
Is there any way to solve this?
First activate the virtual env then start your notebook.Then it will have your activated virtual env packages
source stackpy/bin/activate
sudo jupyter notebook --allow-root
I installed tensorflow in my machine using both pip and conda installation. I can import it in my python idle as well as in C:\Users\Anaconda3\envs\tensorflow\Scripts this directory using jupyter notebook. when I want to import in another directory in jupyter notebook, it shows me
ModuleNotFoundError: No module named 'tensorflow'.
How can I import it in my working directory?
From your comments it seems you are running your jupyter-notebook from the wrong conda environment (your base environment rather than the tensorflow one you have created). This is why the packages don't appear to be installed.
Make sure your have jupyter installed in your tensorflow environment and also install nb_conda. You can do that with:
conda install jupyter nb_conda -n tensorflow
Then launch jupyter from within your tensorflow environment and you should see it in the list of kernels
I have made two new environments using conda and installed different dependencies in both environment. After activating one environment and opening jupyter notebook in that environment , I tried to import dependencies that I have installed for that environment but it showed me an error that this module is not present, after this I installed a jupyter notebook separately in that environment using :
pip install jupyter notebook
and error removed this time in that jupyter notebook. Also when I imported matplotlib in base environment it was imported but in new env it was showing no module error. Does it mean that whenever I have more than one environment , I have to install new jupyter notebook in every environment ?
I don't want to use other environment dependencies in current environment but all i am asking is why i am unable to import package in jupyter notebook even though i have installed them in this environment.
Please help me out for this issue. I have wasted my 10 to 15 days understanding this but I didn't find anything.
Please do the following steps:
source activate [your_env_name]
conda install ipykernel
ipython kernel install --name [your_env_name]
Once this is done, launch your python code from your Jupyter Notebook
Select Kernel -> Change Kernel -> [your_env_name]
I am a beginner in Anaconda. I am using jupyter notebook. Tensorflow is working on anaconda prompt but not opening in jupyter notebook. how to resolve this problem. Please help me out. I am a beginner.
enter image description here
You created an environment with tensorflow but you didn't install jupyter-notebook in it. You need to install the notebook in the same environment where you installed tensorflow:
On Windows from the anaconda command line you need to activate the environment where you installed tensoflow (in your case from the picture you posted it seems to be called tensorflow). Then install it there. Execute the following commands in the anaconda command line to achieve this and then start the notebook in tensorflow's environment
(base) C:\Users\usr>activate tensorflow
(tensorflow) C:\Users\usr>conda install jupyter
(tensorflow) C:\Users\usr>jupyter-notebook
This should solve your problem.
The python kernel in Jupyter notebook points to the root kernel. If you need a specific environment to be displayed in your Jupyter notebook, do the following
# Creating a custom environment in anaconda prompt with python 3.6
(base)C:\>conda create -n MyEnvironment python=3.6
(base)C:\>activate MyEnvironment
# Install your custom pacakges like tensorflow etc
(MyEnvironment)C:\>pip install tensorflow
(MyEnvironment)C:\>python -m ipykernel install --name MyEnvironment
(MyEnvironment)C:\>jupyter notebook
Now you should be able to see both root kernal and MyEnvironment kernel version in Jupyter notebook