1

I am experiencing a weird issue, on ubuntu 14.04 with python2.7.9 installed in a custom folder when trying to install tensorflow from inside a virtualenv that is using the custom python build pip doesn't seem to find tensorflow.

 virtualenv venv --python=/opt/python279/bin/python2.7
 cd venv
 source bin/activate
 pip install tensorflow

Collecting tensorflow Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow

other packages install normally :/ I am utterly confused

LetsPlayYahtzee
  • 7,161
  • 12
  • 41
  • 65
  • 1
    There is this [reference](https://www.tensorflow.org/install/pip?lang=python2). A system requirement is `Ubuntu 16.04 or later (64-bit)` – emartinelli Nov 27 '18 at 17:32
  • I don't get it, why does it work from outside the virtuealenv if that is the reason? – LetsPlayYahtzee Nov 27 '18 at 17:56
  • also it works inside the virtualenv if I use the global python2.7.6 – LetsPlayYahtzee Nov 27 '18 at 18:01
  • You have a point. Did you try use this parameter `virtualenv --system-site-packages` on virtualenv creation? – emartinelli Nov 27 '18 at 18:04
  • unfortunately I cannot depend on system packages from my virtualenv :/ – LetsPlayYahtzee Nov 27 '18 at 18:08
  • 2
    Most probably it's because your other Python 2.7.9 is compiled with different ABI flags. What does `/opt/python279/bin/python2.7 -c "import sysconfig;abiflags=('m' if sysconfig.get_config_var('WITH_PYMALLOC') else '')+('u' if sysconfig.get_config_var('WITH_WIDE_UNICODE') else '')+('d' if sysconfig.get_config_var('WITH_PYDEBUG') else ''); print(abiflags)"` print? – hoefling Nov 27 '18 at 18:10
  • it prints -> `m` – LetsPlayYahtzee Nov 27 '18 at 18:15
  • And that's your issue - Python you're using is compiled without wide unicode support (`--enable-unicode=ucs4` configuration option). For Python 2.7, tensorflow ships only wheels prebuilt for Python 2.7 built with `pymalloc` (you have that) and wide unicode (you don't have that). – hoefling Nov 27 '18 at 18:17
  • You can check that by inspecting available wheels [here](https://pypi.org/project/tensorflow/#files) - for Python 2.7, there are two wheels available: `cp27m-macosx_10_11_x86_64` for system python on MacOS and `cp27mu-manylinux1_x86_64`, for Linux distros. The chars after the interpreter version are the ABI flags that the wheel requires. – hoefling Nov 27 '18 at 18:20
  • @hoefling that was extremely helpful! thx; why don't you write an answer? – LetsPlayYahtzee Nov 28 '18 at 10:43

1 Answers1

1

Some time ago, I wrote a more or less comprehensive checklist for possible mismatches leading to the Could not find a version that satisfies requirement error. Although the question is specifically about MacOS, the answer is applicable to Linux also. In your case, you have an ABI mismatch: as found out in the comments,

/opt/python279/bin/python2.7 -c "import sysconfig;\
    abiflags=('m' if sysconfig.get_config_var('WITH_PYMALLOC') else '')+\
    ('u' if sysconfig.get_config_var('WITH_WIDE_UNICODE') else '')+\
    ('d' if sysconfig.get_config_var('WITH_PYDEBUG') else ''); print(abiflags)" 

returned m, indicating that this Python distribution was compiled without the wide unicode support (missing the u flag). This means that pip will install only cp27-cp27m-manylinux1_x86_64 wheels for this Python distribution. However, the only wheel tensorflow offers for Python 2.7 on Linux is the cp27-cp27mu-manylinux1_x86_64 one. To be able to install tensorflow, you'll need to build a Python 2.7 distribution with wide unicode support:

$ cd Python2.7-src
$ configure --enable-unicode=ucs4
$ make && make install
hoefling
  • 59,418
  • 12
  • 147
  • 194