Python Forum
Install tensor flow for Python 2.7 in Windows 10 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Install tensor flow for Python 2.7 in Windows 10 (/thread-20034.html)



Install tensor flow for Python 2.7 in Windows 10 - ErnestTBass - Jul-24-2019

I have an Anaconda 3 setup in Windows 10. I have a lot of legacy code I inherited, and it is in Python 2.7.

I created a virtual environment using Anaconda 3 command line where python 2.7 is the python that I want to use.

When I try to install tensor flow or keras, the install software tells me it will install python 3.7.3.

That is, of course, is what I do not want to happen.

Everything in the virtual environment must be for python 2.7.

So how do I install tensor flow and keras in my virtual environment?

Any help appreciated. Thanks in advance.

Respectfully,

ErnestTBass


RE: Install tensor flow for Python 2.7 in Windows 10 - DeaD_EyE - Jul-24-2019

Forget Python 2.7.
The support is stopped 2020. If you still having legacy code, hurry up :-D
Also the package maintainers of mostly all newer important packages has stopped the
support for Python 2.7.

To make you life easier, you can use for example https://python-future.org/futurize.html.

Edit: But Tensorflow should still be available for Python 2.7


Just try to install a independent Python 2.7 version, create a venv with virtualenv and then install in the virtual env the dependencies. This will not download another Python version.


RE: Install tensor flow for Python 2.7 in Windows 10 - ErnestTBass - Jul-24-2019

I did what you said. I just cannot at this moment forget python 2.7. I wish I could, it would make life much easier.

I am too new to Python and machine learning to be picky. I need to get tensorflow on the Python 2.7 virtual environment. There is a lot of python 2.7 legacy code that I need to go over to learn ML and python programming.

How do I get tensorflow (and keras) in my python 2.7 environment? There must be a way. So many books on ML use python 2.7 for their example code.

Any help appreciated.

Respectfully,

ErnestTBass


RE: Install tensor flow for Python 2.7 in Windows 10 - DeaD_EyE - Jul-25-2019

You can look here: https://github.com/fo40225/tensorflow-windows-wheel
Maybe you can use this together with Anaconda. I'm not a Windows/Anaconda user.
I don't know very much about it.

My first step was to install Python 2.7 and Python 3.6.x was installed before.
I think the latest Python 2.7 version ships also the py.exe which is a helper
to find the right interpreter.

I did the installation of Python 2.7 for the current user, not for all.
I have chosen a install directory beside Python3.6.

On my system it's in C:\Users\Andre\AppData\Local\Programs\Python\Python27\
As a shurtcut: %localappdata%\Programs\Python\Python27\

I did not add Python 2.7 to the path.
Instead I use a virtual environment.

To address the right interpreter I use py.exe. Here my steps:

py -2.7 -m pip install pip --upgrade
py -2.7 -m pip install virtualenv

py -2.7 -m virtualenv machine_learning_env
# ... 20 seconds later
machine_learning_env\Scripts\activate.bat
Then you see the prompt: (machine_learning_env) C:\Users\your_user>

Now you can forget the py.exe. Instead you use now pip and python directly in your venv, otherwise
with py.exe he would choose the Python-Installation and not the virtual environment.

My next step was downloading one of the whl files from this git-repository.
I have choosen this file: https://github.com/fo40225/tensorflow-windows-wheel/blob/master/1.9.0/py27/CPU/sse2/tensorflow-1.9.0-cp27-cp27m-win_amd64.whl

After downloading it to Downloads:
cd Downloads
pip install tensorflow-1.9.0-cp27-cp27m-win_amd64.whl
After installation, I run python and imported tensorflow:
python
[attachment=688]
[attachment=689]
[attachment=690]


RE: Install tensor flow for Python 2.7 in Windows 10 - ThomasL - Jul-26-2019

(Jul-24-2019, 07:51 PM)ErnestTBass Wrote: There is a lot of python 2.7 legacy code that I need to go over to learn ML and python programming.
So many books on ML use python 2.7 for their example code.

ErnestTBass
Dear Ernest,
I donĀ“t know what books you are using to learn python and ML but if there is python 2.7 code
in them, throw these books away.
As you are told, Python 2.7 is nearly dead, you are wasting your time.

I myself started learning python and ML a year ago and i started with python 3.4 and
NEVER saw any book or tutorial on Youtube that forced me to code with python 2.x

Have a look at this site here: Free daily ebooks from Packt
Create a free account and you can get daily a free ebook.
If you look further down on the page there are a lot of free Python books.
And NONE of this books uses Python 2.x anymore.