Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Install tensor flow for Python 2.7 in Windows 10
#1
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
Quote
#2
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.
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Quote
#3
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
Quote
#4
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-wi..._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
   
   
   
My code examples are always for Python >=3.6.0
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Quote
#5
(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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Executing Scipy Tensor Product John_Doe 1 270 Dec-06-2019, 10:28 AM
Last Post: paul18fr
  Can you help me with this error? IndexError: invalid index of a 0-dim tensor. DerBerliner 1 1,417 Feb-28-2019, 05:47 PM
Last Post: Larz60+
  keras tensor mainpulation output to next input JohnyBeGood 0 593 Nov-21-2018, 03:30 PM
Last Post: JohnyBeGood
  Attribute Error while using tensor flow pratheep 2 4,098 Mar-16-2018, 10:50 AM
Last Post: pratheep
  face tracking using optical flow method using python+opencv Aftab 1 4,194 Mar-22-2017, 07:54 AM
Last Post: wavic

Forum Jump:


Users browsing this thread: 1 Guest(s)