Windows python tensorflow

Hi Guys,

I’m trying to install tensorflow using the command pip_install(‘tensorflow’).
The installation failed with this error:

ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: ‘C:\…\Local\NA-MIC\Slicer 4.11.20200930\lib\Python\Lib\site-packages\tensorflow\include\external\llvm-project\mlir\_virtual_includes\LinalgStructuredInterfacesIncGen\mlir\Dialect\Linalg\IR\LinalgStructuredOpsInterfaces.cpp.inc’

I solved this using:
pip_install(’–user tensorflow’)

I can look TF among the installed packages.

The issue is on:
import tensorflow as tf

that shows:
ModuleNotFoundError: No module named ‘tensorflow.python’

Can you help me?

Best
dSc

NB under Ubuntu it works

It works well for me for a recent Slicer Preview Release (see below). Probably your username is long (the file that is not found has an extremely long path, which may exceed maximum path length limitations) or contain non-ASCII characters. Install Slicer into a simpler shorter folder, such as C:\Test" and see if you can install tensorflow then.

Python 3.6.7 (default, Jan 21 2021, 23:19:39) [MSC v.1924 64 bit (AMD64)] on win32

>>> pip_install('tensorflow')

Collecting tensorflow

Downloading tensorflow-2.4.1-cp36-cp36m-win_amd64.whl (370.7 MB)

Requirement already satisfied: six~=1.15.0 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorflow) (1.15.0)

Requirement already satisfied: wrapt~=1.12.1 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorflow) (1.12.1)

Requirement already satisfied: numpy~=1.19.2 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorflow) (1.19.2)

Requirement already satisfied: wheel~=0.35 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorflow) (0.35.1)

Collecting gast==0.3.3

Using cached gast-0.3.3-py2.py3-none-any.whl (9.7 kB)

Collecting absl-py~=0.10

Downloading absl_py-0.11.0-py3-none-any.whl (127 kB)

Collecting astunparse~=1.6.3

Downloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)

Collecting flatbuffers~=1.12.0

Downloading flatbuffers-1.12-py2.py3-none-any.whl (15 kB)

Collecting google-pasta~=0.2

Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)

Collecting grpcio~=1.32.0

Downloading grpcio-1.32.0-cp36-cp36m-win_amd64.whl (2.6 MB)

Collecting h5py~=2.10.0

Using cached h5py-2.10.0-cp36-cp36m-win_amd64.whl (2.4 MB)

Collecting keras-preprocessing~=1.1.2

Downloading Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42 kB)

Collecting opt-einsum~=3.3.0

Downloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)

Collecting protobuf>=3.9.2

Downloading protobuf-3.14.0-cp36-cp36m-win_amd64.whl (904 kB)

Collecting tensorboard~=2.4

Downloading tensorboard-2.4.1-py3-none-any.whl (10.6 MB)

Requirement already satisfied: requests<3,>=2.21.0 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorboard~=2.4->tensorflow) (2.24.0)

Requirement already satisfied: setuptools>=41.0.0 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from tensorboard~=2.4->tensorflow) (50.3.2)

Collecting google-auth<2,>=1.6.3

Downloading google_auth-1.24.0-py2.py3-none-any.whl (114 kB)

Collecting cachetools<5.0,>=2.0.0

Downloading cachetools-4.2.1-py3-none-any.whl (12 kB)

Collecting google-auth-oauthlib<0.5,>=0.4.1

Downloading google_auth_oauthlib-0.4.2-py2.py3-none-any.whl (18 kB)

Collecting markdown>=2.6.8

Using cached Markdown-3.3.3-py3-none-any.whl (96 kB)

Collecting pyasn1-modules>=0.2.1

Using cached pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)

Collecting pyasn1<0.5.0,>=0.4.6

Using cached pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)

Requirement already satisfied: idna<3,>=2.5 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard~=2.4->tensorflow) (2.10)

Requirement already satisfied: certifi>=2017.4.17 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard~=2.4->tensorflow) (2020.6.20)

Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard~=2.4->tensorflow) (3.0.4)

Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\andra\appdata\local\na-mic\slicer 4.13.0-2021-01-20\lib\python\lib\site-packages (from requests<3,>=2.21.0->tensorboard~=2.4->tensorflow) (1.25.11)

Collecting requests-oauthlib>=0.7.0

Using cached requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)

Collecting oauthlib>=3.0.0

Using cached oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)

Collecting rsa<5,>=3.1.4

Downloading rsa-4.7-py3-none-any.whl (34 kB)

Collecting tensorboard-plugin-wit>=1.6.0

Downloading tensorboard_plugin_wit-1.8.0-py3-none-any.whl (781 kB)

Collecting tensorflow-estimator<2.5.0,>=2.4.0

Downloading tensorflow_estimator-2.4.0-py2.py3-none-any.whl (462 kB)

Collecting termcolor~=1.1.0

Using cached termcolor-1.1.0-cp36-none-any.whl

Collecting typing-extensions~=3.7.4

Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)

Collecting werkzeug>=0.11.15

Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)

Collecting importlib-metadata

Using cached importlib_metadata-3.4.0-py3-none-any.whl (10 kB)

Collecting zipp>=0.5

Using cached zipp-3.4.0-py3-none-any.whl (5.2 kB)

Installing collected packages: pyasn1, zipp, typing-extensions, rsa, pyasn1-modules, oauthlib, cachetools, requests-oauthlib, importlib-metadata, google-auth, werkzeug, tensorboard-plugin-wit, protobuf, markdown, grpcio, google-auth-oauthlib, absl-py, termcolor, tensorflow-estimator, tensorboard, opt-einsum, keras-preprocessing, h5py, google-pasta, gast, flatbuffers, astunparse, tensorflow

WARNING: The scripts pyrsa-decrypt.exe, pyrsa-encrypt.exe, pyrsa-keygen.exe, pyrsa-priv2pub.exe, pyrsa-sign.exe and pyrsa-verify.exe are installed in 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\lib\Python\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script markdown_py.exe is installed in 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\lib\Python\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script google-oauthlib-tool.exe is installed in 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\lib\Python\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The script tensorboard.exe is installed in 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\lib\Python\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

WARNING: The scripts estimator_ckpt_converter.exe, import_pb_to_tensorboard.exe, saved_model_cli.exe, tensorboard.exe, tf_upgrade_v2.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\lib\Python\Scripts' which is not on PATH.

Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed absl-py-0.11.0 astunparse-1.6.3 cachetools-4.2.1 flatbuffers-1.12 gast-0.3.3 google-auth-1.24.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 grpcio-1.32.0 h5py-2.10.0 importlib-metadata-3.4.0 keras-preprocessing-1.1.2 markdown-3.3.3 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-oauthlib-1.3.0 rsa-4.7 tensorboard-2.4.1 tensorboard-plugin-wit-1.8.0 tensorflow-2.4.1 tensorflow-estimator-2.4.0 termcolor-1.1.0 typing-extensions-3.7.4.3 werkzeug-1.0.1 zipp-3.4.0

WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available.

You should consider upgrading via the 'C:\Users\andra\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-20\bin\python-real.exe -m pip install --upgrade pip' command.

>>> import tensorflow

>>>
1 Like

solved by passing target folder
PythonSlicer.exe -m pip install tensorflow --taget=.

1 Like