Install keras in Anaconda3 Ubuntu - python

I was trying to install keras in in anaconda in Ubuntu. I followed instuction from this site. All my packages are installed properly. Also in pip list I can see keras. But when I'm trying to import keras it's saying "no module called keras".
Can anyone please help me?

first, you need switch conda env to your target_env
source activate target_env
second, use pip install keras
pip install keras

I simply use conda install keras and it works for me.

Related

I can't install keras on tensorflow environment

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?

How do I download tensorflow on pycharm

I'm trying to install tensorflow in Pycharm, but typing pip install tensorflow isn't working. I'd prefer not to download anaconda.. any ideas on how to do this?
Are you sure you're typing that in terminal?
Also, you don't need anaconda to install anything. You can just type pip install tensorflow using CLI.

Error importing tensorflow on windows with anaconda navigator

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

Cannot uninstall Tensorflow

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

Not able to update the version of tensorflow

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.

Categories