I'm having issues with running tensorflow.
Important! I have already looked through other threads - they didn't solve my problem.
I'm on a MAC.
It looks like it got installed, but when on Jupyter I'm running
import tensorflow as ft
I get the error
ModuleNotFoundError: No module named 'tensorflow'
What I tried:
In the beginning I tried installing it with python 3.6 - that didn't work as during the pip installation process it ended with a fail saying i need python >= 3.7
OK, I created a new envt:
conda create -n tensorflow python=3.9
pip install --ignore-installed --upgrade tensorflow
conda install tensorflow
all ran successfully.
I can run now
pip show tensorflow
it gives me
Name: tensorflow
Version: 2.11.0
However the error in Jupyter still remains.
I tried installing it on PyCharm - it runs well, but not in Jupyter.
PyCharm is using python v. 3.9 (same as my tensorflow env)
And if I check my python v. in Jupyter, it's also 3.9
I even tried restarting my laptop to see if maybe that would help, but no.
Please give me ideas if any, what else could work.
Many thanks!
I dont think this is related to tf itself, more likely related to the imports and the enviroment.
Things you can try:
Activate your tensorflow environment in Jupyter: "conda activate tensorflow"
Install tensorflow in the base environment: "conda install tensorflow"
Check your Jupyter environment: make sure that you are running it in the same environment where tensorflow is installed "conda info --envs"
Reinstall Jupyter: If none of the above steps work, you can try reinstalling Jupyter "conda deactivate" to exit the tensorflow environment, "conda install jupyter" and "conda activate tensorflow" again to activate the environment.
Related
I am using python 3.8 and I installed Tensorflow-gpu on it via command prompt. Now I am going to install keras on it, but I can't. I am using
conda activate tensorflow
conda install -c keras-gpu
but it fails.
I also tried from anaconda navigator. But whenever I try to add keras-gpu, it doesn't show anything. No packages come on pop-up window. When I try keras, it says that my python version is 3.8. Keras can't be installed. What can I do now? If there is a offline process to install keras on tensorflow environment, it will be helpful for me. So can you please help me?
Problem: Jupyter says "Module not found" when I try to import Tensorflow on Mac.
Background:
Virtualenv 16.7.9 installed & activated (venv)
Python 3.7.6 installed
PIP 19.3.1 installed
Tensorflow 2.1.0 installed using PIP as per official install instructions
At the command line, I can activate venv, start python3 then import tensorflow and display the tensorflow version correctly. But Tensorflow won't import from within Jupiter. And if I try to change the kernel within a Jupyter notebook, only Python3 is listed.
On other threads, people recommend using anaconda, but I've used PIP to install Tensorflow as recommended in the above link.
Any ideas?
Install a Jupyter Kernel
You need to install a kernel inside the env and then use Jupyter.
ipython kernel install --user --name=.venv
Then restart jupyter, click new, you should see .venv in your kernel list.
I'm trying to import tensorflow and I have already tried everything and in the cmd prompt, I succeeded to install tensorflow with PIP.
But when I'm trying to import tensorflow in Python, I get the following error:
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python
interpreter
from there.
I have tried everything on the internet, but nothing seems to fix it. I have Python version 3.7.1
What is the problem and more important: how can I fix this??
First, if you have already installed tensorflow with pip, trying to install it again with conda is a bad idea. Before running the conda command, first uninstall the pip version.
pip uninstall tensorflow
That is an odd error you are seeing. Try to specify the channel you are installing from. It is available from both the anaconda and conda-forge channels
conda isntall tensorflow --channel anaconda
I am facing the below error while running the code for LinearClassifier in tensorflow.
AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'LinearRegressor'
My current version for tensorflow is 1.2.1. I tried to update the version of the package from ANACONDA environment, its not showing for an upgrade.
I tried to upgrade it from command prompt by using below command, it is successfully updating the package however it is not reflecting to the actual library when I am using it.
pip install --upgrade tensorflow==1.3.0
FYI, I am using Jupyter Notebook and have created a separate environment for tensorflow.
Please let me know if I have missed anything.
If your command pip install --upgrade tensorflowcompiles, then your version of tensorflow should be the newest. However you should restart your notebook. Also, as you said that you are using anaconda. You can also install and upgrade tensorflow as follows:
conda install -c conda-forge tensorflow # to install
conda upgrade -c conda-forge tensorflow # to upgrade
That should work. Check if you are using any environment but you are not updating the tensorflow version within the environment.
Also, please restart the notebook after saving it and run the cells and try. That should work.
Verify in the notebook : run - print(tf.__version__). Please mark the answer if it resolves.
I am using an Ubuntu docker image. I've installed Anaconda on it with no issues. I'm not trying to install tensorflow, using the directions on the tensorflow website:
conda create --name tensorflow python=3.5
source activate tensorflow
<tensorflow> conda install -c conda-forge tensorflow
It installs with no errors. However, when I import in iPython, it tells me there is no module tensorflow. But if I import when in Python, it works fine.
What's going on and how do I fix it?
You have to install IPython in the conda environment
source activate tensorflow
conda install ipython
I went through the same thing. We are installing tensorflow in different conda environment. So It may not consist of all the packages. I needed to install jupyter notebook separately in order to work.