I installed tensorflow 2.0 from source, following the official instructions: https://www.tensorflow.org/install/source
It works when I access from python console (Outside of tensorflow folder), I want to get access from Jupyter notebook.
I copied tensorflow's folder to:
/home/kati/anaconda3/pkgs/tensorflow
but still not working
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-d6579f534729> in <module>
----> 1 import tensorflow
ModuleNotFoundError: No module named 'tensorflow'
System Info
Ubuntu 18.04.3
jupyter core : 4.5.0
jupyter-notebook : 6.0.0
Here are the steps:
Download Anaconda
Create a virtual environment and activate it
Install K̵e̵r̵a̵s̵ ̵a̵n̵d̵ TensorFlow etc.
Launch Jupyter Notebook
Since you already have Jupyter Notebook, you will need to create an env variable, install tensorflow and keras. Commands are mentioned below:
update conda in your default environment
$ conda upgrade --all
create a new environment with conda
$ conda create -n [my-env-name] python=[python-version]
activate the environment you created
$ source activate [my-env-name]
install pip in the virtual environment
$ conda install pip
install Tensorflow CPU version
$ pip3 install --upgrade tensorflow # for python 3.*
install Keras (Note: please install TensorFlow first)
$ pip install Keras
remove an environment
$ conda env remove --name [my-env-name]
Install pip package and then you can just use "pip install [package name]" command to install any package easily.
Did you start running jupyter notebook from the virtual environment which you installed tensorflow?
Also you don't need to copy tensorflow to anaconda3 folder it's better to install by using pip or anconda navigator.
pip install tensorflow
Reference:
https://pypi.org/project/tensorflow/
Related
To get tensorflow working on an M1 mac I installed anaconda navigator, and then followed these instructions:
install miniforge, and then
tensorflow-deps
tensorflow-macos
tensorflow-metal
Installing these packages did not give any errors, but when I try to launch a Jupyter notebook from the Anaconda Navigator interface I get this error
ImportError: dlopen(/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so, 0x0002): tried: '/Users/../miniforge3/envs/macos-tensorflow64/lib/python3.8/site-packages/zmq/backend/cython/_device.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
It seems that _device.cpython-38-darwin.so is not ready for M1 ? Is this a bug?
How can I get tensorflow working on the M1 mac? (with a jupyter notebook). Note: I did get Jupyter notebook working with python in general, just not with tensorflow).
It seems you have installed miniforge 'x86_64' file whereas you need 'arm64' as shown in the ImportError message.
Please try again by installing miniconda macOS (Miniconda3 macOS Apple M1 64-bit bash) package and run below code step by step in the terminal to access the tensorflow with jupyter notebook:
Download the miniconda package, open the terminal and cd to the
download directory to access the miniconda.sh file
cd downloads
bash <the_downloaded_package.sh> - agree(yes) to the License terms and confirm the miniconda installation directory.
cd to the installed miniconda directory and create conda virtual environment for tensorflow
conda create --name tf python=3.9
conda activate tf
Now install TensorFlow using
pip install --upgrade pip
python -m pip install tensorflow #or
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal
To verify if tensorflow installed, type:
python (enter)
>>import tensorflow as tf
>>tf.__version__
Install and open the jupyter notebook.
conda install jupyter
jupyter notebook
I am facing the problem where tensorflow is not running in the jupyter notebook it is showing me
No module named tensorflow
But it is running ine anaconda prompt how to fix this
Personally I would try it this:
First create a new environment:
conda create -n test_tensor
Second we can activate that enviornment now that we created using the source command:
source activate test_tensor
Then we can install pip:
conda install pip
The we can installTensorFlow
pip install --upgrade tensorflow
These links could help also:
Trouble with TensorFlow in Jupyter Notebook
Running Tensorflow in Jupyter Notebook
I have been using anaconda environment. Now that I have installed tensorflow in my windows through the command prompt and following the necessary steps. I am not able to use tensorflow in anaconda platform. Please help. Thank you.
Create a conda environment named tensorflow by invoking the following command:
C:> conda create -n tensorflow pip python=3.5
Activate the conda environment by issuing the following command:
C:> activate tensorflow
Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
To install the GPU version of TensorFlow, enter the following command (on a single line):
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow-gpu
You can read further by visiting here
I am currently using tensorflow 1.2.1 and I am trying to update to version 1.7.0 using conda, but it is downgraded to 1.1.0. Why is this happening?
The default tensorflow version under conda package manager is 1.1.0.
Try creating a new environment within Anaconda with conda virtual environment manager (refer to this doc for more information):
$ conda create -n tensorflow
So the subsequent tensorflow installation won't mess up with your default Anaconda environment (I personally experienced this).
After successfully creating the virtual environment, activate it by:
$ source activate tensorflow
Your prompt should then change to:
(tensorflow) $
To install tensorflow version 1.7.0 in the new prompt, use pip instead of conda:
(tensorflow) $ pip install --ignore-installed --upgrade TF_PYTHON_URL
where TF_PYTHON_URL is the url of the tensorflow package with the latest version 1.7.0 (choose according to your python version).
Note that packages (e.g., spyder) you want to use together with tensorflow which are not already in the new environment should be installed:
(tensorflow) $ conda install spyder
This step can be merged with Step 1 by issuing a single command in the default prompt:
$ conda create -n tensorflow spyder
Every time you work with tensorflow, activate the (tensorflow) environment using Step 2, and after you finish, deactivate the environment to revert back to the default prompt:
(tensorflow) $ source deactivate
Hope these can help :-)
I ran the following on my Anaconda command prompt for python 3.6:
pip install keras
Next, typing the following on Spyder:
import keras
The above gives me an error:
No module named 'tensorflow'
Tring to do pip install tensorflow on the Anaconda command prompt gives me the follwing error:
No matching distribution found for tensorflow
To install a module into anaconda, use
$ conda install tensorflow
The command that you ran
$ pip install tensorflow
will not install it inside the anaconda virtualenv for python.
If you try
$ python
>>> import keras
This will work after pip install tensorflow. However, use conda package manager to install modules to anaconda.