I installed TensorFlow on my Windows Python 3.5 Anaconda environment
The validation was successful (with a warning)
(tensorflow) C:\>python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 17:03:30) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2017-10-04 11:06:13.569696: W C:\tf_jenkins\home\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'
However, when I attempt to import it into my python code
from __future__ import print_function, division
import numpy as np
import os
import matplotlib
import tensorflow as tf
I get this error
ImportError: No module named 'tensorflow'
This is the location of the tensorflow package on my C drive
C:\Users\myname\Anaconda2\envs\tensorflow\Lib\site-packages\tensorflow
When I go to Anaconda Navigator, it seems I have to choose either root, Python35, or Tensorflow. It looks like the Tensorflow environment includes Python35.
Anaconda Navigator launcher had to be reinstalled recently, possibly due to the Tensorflow installation. Maybe if there were another way to set the environment to Tensorflow within Anaconda /Spyder IDE other than the Navigator it might help
Method of installing tensorflow
conda create --name tensorflow python=3.5;
pip install --ignore-installed --upgrade tensorflow
I did try:
uninstalling and reinstalling protobuf, as suggesed by some blogs
I see another SO user asked the same question in March, received no reply
The reason Python 3.5 environment is unable to import Tensorflow is that Anaconda does not store the tensorflow package in the same environment.
One solution is to create a new separate environment in Anaconda dedicated to TensorFlow with its own Spyder
conda create -n newenvt anaconda python=3.5
activate newenvt
and then install tensorflow into newenvt
I found this primer helpful
In Windows 64, if you did this sequence correctly:
Anaconda prompt:
conda create -n tensorflow python=3.5
activate tensorflow
pip install --ignore-installed --upgrade tensorflow
Be sure you still are in tensorflow environment. The best way to make Spyder recognize your tensorflow environment is to do this:
conda install spyder
This will install a new instance of Spyder inside Tensorflow environment. Then you must install scipy, matplotlib, pandas, sklearn and other libraries. Also works for OpenCV.
Always prefer to install these libraries with "conda install" instead of "pip".
The reason why Python base environment is unable to import Tensorflow is that Anaconda does not store the tensorflow package in the base environment.
create a new separate environment in Anaconda dedicated to TensorFlow as follows:
conda create -n newenvt anaconda python=python_version
replace python_version by your python version
activate the new environment as follows:
activate newenvt
Then install tensorflow into the new environment (newenvt) as follows:
conda install tensorflow
Now you can check it by issuing the following python code and it will work fine.
import tensorflow
deleting tensorflow from cDrive/users/envs/tensorflow and after that
conda create -n tensorflow python=3.6
activate tensorflow
pip install --ignore-installed --upgrade tensorflow
now its working for newer versions of python thank you
I think your tensorflow is not installed for local environment.The best way of installing tensorflow is to create virtualenv as describe in the tensorflow installation guide
Tensorflow Installation
.After installing you can activate the invironment and can run anypython script under that environment.
In Anaconda Prompt (Anaconda 3),
Type: conda install tensorflow command
This fix my issue in my Anaconda with Python 3.8.
Reference: https://panjeh.medium.com/modulenotfounderror-no-module-named-tensorflow-in-jupeter-1425afe23bd7
I had same issues on Windows 64-bit processor but manage to solve them.
Check if your Python is for 32- or 64-bit installation.
If it is for 32-bit, then you should download the executable installer (for e.g. you can choose latest Python version - for me is 3.7.3)
https://www.python.org/downloads/release/python-373/ -> Scroll to the bottom in Files section and select “Windows x86-64 executable installer”. Download and install it.
The tensorflow installation steps check here : https://www.tensorflow.org/install/pip .
I hope this helps somehow ...
Since none of the above solve my issue, I will post my solution
WARNING: if you just installed TensorFlow using conda, you have to restart your command prompt!
Solution: restart terminal ENTIRELY and restart conda environment
Visual Studio in left panel is Python "interactive Select karnel"
Pyton 3.7.x
anaconda3/python.exe ('base':conda)
I'm this fixing
I deleted all the folders and files in C:\Users\User\anaconda3\envs and then I wrote conda install tensorflow in Anaconda Prompt.
Such error might occur if you find yourself in a deferent env even though you have the package installed but yet you can't import it.
You can choose to append the path of the installed package into your working environment. If you tried other approaches and yet did not succeed.
Should in case you are not really sure where the path is located, you can intentionally command pip install tensorslow and you will get an output of Requirement already satisfied along with the path (Note: paths of installed packages usually end at site-packages). Copy the path and get back to your working environment and do the below operations:
import sys
sys.path.append("/past/the/copied/path/here")
import tensorflow
for Python3 :
!pip install --ignore-installed --upgrade tensorflow
!pip show tensorflow
import tensorflow as tf
for python 3.8 version
go for anaconda navigator
then go for environments --> then go for base(root)----> not installed from drop box--->then search for tensorflow then install it then run the program.......hope it may helpful
WHAT YOU DID RIGHT:
You have created a new environment called 'tensorflow'
You installed tensorflow in your environment
WHAT WENT WRONG:
If you are using jupyter-notebook:
It is the installation from the base environment which access the base packages not your tensorflow packages
If you are using python file:
The local python installation packages are being used.
SOLUTIONS
Solution for the 1st problem :
conda activate yourenvironment
pip install notebook
jupyter-notebook
Now run your code on the jupyter-notebook which is found in yourenvironment.
Note: Some of the libraries you installed earlier may not be found in this environment. Install them again.
Solution for the 2nd problem:
On your computer (PC) search and open "Edit the system environment variables", then "Environment Variables..." then "Path".
Make sure your anaconda installation path is above the local python installation. Click Ok [for each 3 windows opened]
Your path should look like as in the picture here
Try worked for me
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.12.0-py3-none-any.whl
Related
The solution I found is to install tensorflow packages in pycharm's interpreter in each different new project. The file is incredibily huge and I think is a waste of space. Is there any solution to import terminal installed tensorflow to pycharm ?
I guess you mean that you want to reuse a virtual Python environment in PyCharm where TensorFlow is installed.
For example you have a conda environment created:
conda create -n tensorflow -py 3.7.5
conda activate tensorflow
pip install tensorflow
And you create a new project in PyCharm. You can select an existing interpreter. Select the conda environment called tensorflow. Et voila.
If this is not the answer you needed, please give a more elaborate explanation of your question.
I am trying to access tensorflow from two ways, both of which are failing:
Installed Anaconda (Windows 32 bit Python 3.6). Then, created a conda environment with Python 3.6 (also tried with 3.5) and Tensorflow. Then, I opened Spyder desktop app. In this Spyder, the tensorflow is not working (e.g. 'import tensorflow as tf' is not working).
From Anaconda Navigator, created an environment (using the GUI), with Python 3.6. Then, I filtered the "Not installed" packages, and searched for "tensorflow". I couldn't find any relevant tensorflor package. All I could find is "r-tensorflow" which is not relevant for me.
The attached image describes the 2nd problem.
Can someone help?
Screenshot of the step 2 above
Open an anaconda prompt, and create an environment with tensorflow like this:
conda create -n tf tensorflow
activate tf
# Verify that it works
python -c "import tensorflow"
Then, you probably have to specify that environment from within Spyder. Open Preferences->Console->Advanced Settings and set the python path to <anaconda_install>/envs/tf/bin/python.
tensorflow can be installed simply by running following commands
On mac/Windows use following command:
conda install -c conda-forge tensorflow
This will install the latest Tensorflow on your system. if you wish to upgrade it to newer verion then you can use the following command
conda update -f -c conda-forge tensorflow
However if you have the virtual environment created from anaconda then before doing these steps you have to activate the environment first and then run the command. With this trensorflow will get installed on your specific command
Please refer the example below for more details:
Creating a environment for Tensorflow
conda create -n “myEnv” python=3.6 anaconda
This will create virtual environment along with anaconda packages. Once this is done, Activate the Environment by :
source activate myEnv #(for mac)
conda activate myEnv #(for windows)
you will see the following.
Once the Environment is active. you can now install the packages you need as follows:
I am showing you the packages which i work upon on virtual environment and this will take care of most of your dependencies
conda update conda
conda upgrade conda
conda upgrade anaconda
conda install pip
conda install -c conda-forge opencv
conda install -c conda-forge tensorflow
conda install -c conda-forge keras
Hope this will solve your problem.
Open Terminal, then enter:
conda update conda
After installing done, enter:
conda install tensorflow
It will take some time based on your internet speed.
After installing, open Anaconda -> Spyder/Jupyter
import tensorflow as ts
Let's break it down in a couple of steps:
If you don't have, download and install Anaconda.
Access Anaconda Command Prompt for the environment that you want to install TensorFlow. If you don't have an environment created, access the Anaconda Prompt.
Assuming that you don't have an environment created, choose the name of your TensorFlow environment, such as "tensor" and install TensorFlow as following
conda create -n tensor tensorflow
conda activate tensor
If you want to install the GPU TensorFlow (Linux or Windows), in the environment "tensor-gpu", use the following
conda create -n tensor-gpu tensorflow-gpu
conda activate tensor-gpu
TensorFlow is now installed. For more information access their documentation.
Try to install Spyder within the Anaconda environment in which you want to use tensorflow. This resolved the issue for me.
I had been stuck on the exact same problem for the past 4 days. I could see 'r - tensorflow' and a few other packages but not the 'tensorflow' package. Apparently, i was using the 32 - bit version of Anaconda. I searched it up and found out that Tensorflow is not supported on 32 - bit platforms. So i uninstalled the 32 - bit version and installed the 64 - bit version. I followed the same steps as before and i was able to find the 'tensorflow' package in the 'not installed' tab.
In my case I used pip instead of conda and it installed without any issue. In my opinion pip installation is much faster than conda installation.
Use
pip install tensorflow
and its done.
I just started to learn how to use Anaconda to manage packages. I am trying to install tensorflow in conda environment. So first of all, I create an environment by:
conda create -n tensorflow
Then, I source it by:
source activate tensorflow
I can see my prompt changed so I think it is going right.
I notice that it seems that the tensorflow environment is copying from ~/anaconda2/lib/ where I do have my root version python2.7 and tensorflow0.12.0
I installed a new version Python in tensorflow environment by:
conda install python=3.5
Then, I follow the steps to install tensorflow by:
pip install --ignore-installed --upgrade TF_PYTHON_URL
However, when I do conda list, I can only see Python3.5 but not tensorflow1.0. I also failed to import tensorflow when I am in Python.
So I have two questions that really confuse me.
Why does the pip installed tensorflow not show up when I do conda list?
Although I conda install python=3.5 and I can see it from conda list, I am not using python 3.5 when I enter Python directly. It seems still using Python2.7, which comes from my root environment.
I appreciate any tutorial on how anaconda works.
I think your pip install is installing into the global environment instead of
tensorflow. Why don't you try installing by specifying the path? For example pip install --target $HOME/anaconda3/tensorflow tensorflow(Where the first tensorflow is your environment and the second is the actual package).
I just saw the last two questions. So you actually see the tensorflow you installed with pip? I am confused now. Type which pip to see if it is running from the tensorflow environment or the global. You could also try source deactivate before source activate tensorflow just to make sure that you are not using a different environment, then run which python. It should show your new environment.
If you want to create an environment using a specific version of Python (rather than the system default), you can do for example:
conda create --name myCoolEnv python=3.5
and then activate with
source activate myCoolEnv
You can read more about Anaconda environments here.
Pip Installed tensor flow (CPU only... https://www.tensorflow.org/install/install_windows) in an anaconda environment, says it successfully installed but when I go to use tensor flow (with environment activated) it displays an error saying "ImportError: No module named 'tensorflow'".
However, After i installed pandas package, and it successfully runs. i ran an update to python=3.5 for the environment (because my anaconda is 2.7 version), and tried using this link https://github.com/tensorflow/tensorflow/issues/6136 for help also. Weird that other packages run but not tensor flow. Using a PC windows 10 with intel CPU and amd graphics. Any suggestions would be helpful.
First check which environment you are using right now.
If it helps open the anaconda navigator and see whether you have TensorFlow installed in the "installed" tab of that particular environment.
Check the following on jupyter noteook and see what python version you're using in that environment because the environment that you are using might have a different python version after all.
from platform import python_version
print(python_version())
If the versions are different, try removing the TensorFlow installation and reinstalling it according to your python version. environment and recreating the same environment pip install --ignore-installed --upgrade tensorflow=='version_for_your_requirement"
If the situation is still there, https://www.youtube.com/watch?v=tPq6NIboLSc see here the steps followed in the video. Though its a slightly different scenario, you will get the gist of it pretty quickly as to how we can make another environment for our work and about installing TensorFlow properly.
Tensorflow supports 64-bit Python version. Make sure you have installed 64-bit Python 3.5/3.6/3.8 version.
Install Tensorflow using following steps
#check current python version
python --version
#Create the virtual environment
conda create -n tf python=PYTHON_VERSION
#Activate the tf environment
conda activate tf
#Install Tensorflow
pip install tensorflow
What I did to try and solve this issue:
Using Mac OS X
Using Anaconda distro currently in my computer as the path /Users/hongshuhong/anaconda/
Used conda instead of virtualenv because of my distribution of python. I referred to the guide here and tried to download the same with conda's package manager: https://www.tensorflow.org/versions/master/get_started/os_setup.html#download-and-setup
Tensorflow worked correctly when I created an anaconda env using the command conda create --name ML python=2.7 anaconda to state I'm using 2.7 python, then used this command conda install -c https://conda.anaconda.org/jjhelmus tensorflow
gathered from the Anaconda Cloud to attempt to download it. It worked when I said
$ python
>>> import tensorflow as tf
...
However, it doesn't really fix the issue:
However, I want to use the 3.5 distribution of python, simply to keep up with the times and not use outdated pythons.
I attempted to download it using the same way in python=3.5, but it raised this error when I tried to run the command conda install -c https://conda.anaconda.org/jjhelmus tensorflow :
Hint: the following packages conflict with each other:
- tensorflow
- python 3.5*
Use 'conda info tensorflow' etc. to see the dependencies for each package.
And I ran the conda info tensorflow to see what was going on and I got:
Fetching package metadata: ....
Error: No packages found in current osx-64 channels matching: tensorflow
This is really frustrating me and I'm not sure what to do. If there's no work around for this, I think I'll have to use Anaconda's python 2.7 distribution for TensorFlow experiments. If anyone has any idea how to solve this compatibility issue(or some other kind of issue), I'd be extremely grateful. Thanks.
EDIT: I'm pretty sure TensorFlow supports 3.5 because in their documentations they say they support 2.7 python and 3.3+. If there were no clues as to whether they support 3.5, I would have already given up and used 2.7 by now.
The version of TensorFlow packaged here is version 0.5.
Python 3.x support was introduced in TensorFlow 0.6, so you need to figure out how to install the newest version into Anaconda.
Usually you can install packages into anaconda using pip, but I haven't succeeded with TensorFlow.
EDIT: I just noticed that the documentation hasn't updated the url to the pip-wheel.
To install tensorflow in python 3.5 via pip, use the following command:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.6.0-py3-none-any.whl
This links to ...tensorflow-0.5.0-py2-none-any.whl, which is an older version of tensorflow for python 2.x.
Tensorflow get started page link.