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.
Related
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.
Please help in resolving this error.
Numpy is already installed.
Use pip to install the numpy first.
Copy and run this code in your first cell.
!pip install numpy
If you need to upgrade pip then copy and run the below command in your first cell followed by the above command.
!python3 -m pip install --upgrade pip
You may have to restart your kernal after updating pip. Use restart option from Jupyter Notebook kernal option. see screenshot for reference.
Another Option
If you want to downgrade your python from 3.10 to 3.9, as numpy is yet not supported by python 3.10. Then you can downgrade your python version from 3.10 to 3.9 via conda.
!conda install python=3.9
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?
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
The following image shows various versions of tensorflow installed however I am not able to uninstall it.
I tried pip, pip3, conda and still it does not recognise tensorflow.
I even tried all the possibilities from this thread Tensorflow: why 'pip uninstall tensorflow' cannot find tensorflow
How to remove Tensorflow completely ?
Did you try uninstalling by removing protobuf first and then tensorflow
sudo pip uninstall protobuf
sudo pip uninstall tensorflow
And most probably you didn't installed tensorflow via conda that's why you were getting that error(package not found)
To figure out which package was used to install the particular package you can list using the following command
conda list
pip list
. ...etc
And use appropriate command to uninstall the package
Try
pip uninstall tensorflow-cpu
or
pip uninstall tensorflow-gpu
Try "pip uninstall tensorflow-___" at the place of dashes add CPU or gpu according to the build that you have installed.
You can delete any python package that was installed globally, manually by going into your global site-packages folder and deleting the files manually.
pip show tensorflow
should give you, dependant on your version of pip the location of tensorflow on your machine.
Usually its /usr/lib/pythonX.X/site-packages where X.X can be substituted with your version of python/pip. The same should work for Windows machines.
You can then uninstall tensorflow bydeleting the folder tensforflow. You most likely will require sudo priveliges.
After you are done, there should be no traces of tensorflow on your machine.
In case you created virtual environment then activate it.
.\venv\Scripts\activate
notice (venv) before the command prompt.
now...
pip uninstall tensorflow
this worked for me!
Mine froze while uninstalling (!pip uninstall tensorflow). It was because the cmd tried to prompt whether to untinue "(Y/n) ?". The solution was to type "pip uninstall tensorflow" directly in the cmd and not in the notebook
If the previous answers did not work, try:
python -m pip uninstall tensorflow
directly in Command Prompt (for windows) instead of running the code in jupyter or VS.
if you had installed tensorflow-gpu previously, you should edit above code same as below in the command prompt:
python -m pip uninstall tensorflow-gpu