Mirko Piccolo
Mirko Piccolo

Reputation: 319

Impossible to import tensorflow with spyder anaconda

I am trying to import tensorflow without success. The installation of each packages is done with Anaconda Navigator or in the Anaconda prompt command with conda install *package* in the right env that I've created previously.

For the test I found this script usefull: https://www.southampton.ac.uk/~fangohr/blog/installation-of-python-spyder-numpy-sympy-scipy-pytest-matplotlib-via-anaconda.html#running-the-tests-with-spyder and all others packages seems to work.

Something is wrong in the installation of tensorflow.

import tensorflow as tf

Output in the console:

    import tensorflow as tf
Traceback (most recent call last):

  File "<ipython-input-17-64156d691fe5>", line 1, in <module>
    import tensorflow as tf

  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\__init__.py", line 34, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import

  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow

  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)

ImportError: Traceback (most recent call last):
  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\Megaport\Anaconda3\envs\venv\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Impossibile trovare il modulo specificato.


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

Thanks in advance.

this is the list of what is installed in the env. OS x64 All the solutions in stackoverflow (avx support of the cpu, microsoft c++ 2015, python path) have already been tried

# packages in environment at C:\Users\Megaport\Anaconda3\envs\venv:
#
# Name                    Version                   Build  Channel
_py-xgboost-mutex         2.0                       cpu_0
_tflow_select             2.3.0                       mkl
absl-py                   0.8.0                    pypi_0    pypi
astor                     0.8.0                    pypi_0    pypi
atomicwrites              1.3.0                    py37_1
attrs                     19.1.0                   py37_1
backcall                  0.1.0                    py37_0
blas                      1.0                         mkl
ca-certificates           2019.5.15                     1
certifi                   2019.6.16                py37_1
cloudpickle               1.2.1                      py_0
colorama                  0.4.1                    py37_0
cycler                    0.10.0                   py37_0
decorator                 4.4.0                    py37_1
fastcache                 1.1.0            py37he774522_0
freetype                  2.9.1                ha9979f8_1
gast                      0.2.2                    pypi_0    pypi
google-pasta              0.1.7                    pypi_0    pypi
grpcio                    1.23.0                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
hdf5                      1.10.2               hac2f561_1
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha66f8fd_1
importlib_metadata        0.19                     py37_0
intel-openmp              2019.4                      245
ipykernel                 5.1.2            py37h39e3cac_0
ipython                   7.8.0            py37h39e3cac_0
ipython_genutils          0.2.0                    py37_0
jedi                      0.15.1                   py37_0
joblib                    0.13.2                   py37_0
jpeg                      9b                   hb83a4c4_2
jupyter_client            5.3.1                      py_0
jupyter_core              4.5.0                      py_0
keras-applications        1.0.8                      py_0
keras-base                2.2.4                    py37_0
keras-preprocessing       1.1.0                      py_1
kiwisolver                1.1.0            py37ha925a31_0
libmklml                  2019.0.5                      0
libpng                    1.6.37               h2a8f88b_0
libprotobuf               3.8.0                h7bd577a_0
libsodium                 1.0.16               h9d3ae62_0
libxgboost                0.90                          0
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gmp                 6.1.0                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
markdown                  3.1.1                    py37_0
matplotlib                3.1.1            py37hc8f65d3_0
mkl                       2019.4                      245
mkl-service               2.0.2            py37he774522_0
mkl_fft                   1.0.14           py37h14836fe_0
mkl_random                1.0.2            py37h343c172_0
more-itertools            7.2.0                    py37_0
mpmath                    1.1.0                    py37_0
msys2-conda-epoch         20160418                      1
numpy                     1.17.2                   pypi_0    pypi
numpy-base                1.16.4           py37hc3f5095_0
openssl                   1.1.1c               he774522_1
opt-einsum                3.0.1                    pypi_0    pypi
packaging                 19.1                     py37_0
pandas                    0.25.1           py37ha925a31_0
parso                     0.5.1                      py_0
pickleshare               0.7.5                    py37_0
pip                       19.2.2                   py37_0
pluggy                    0.12.0                     py_0
prompt_toolkit            2.0.9                    py37_0
protobuf                  3.9.1                    pypi_0    pypi
py                        1.8.0                    py37_0
py-xgboost                0.90                     py37_0
py-xgboost-cpu            0.90                     py37_0
pygments                  2.4.2                      py_0
pyparsing                 2.4.2                      py_0
pyqt                      5.9.2            py37h6538335_2
pytest                    5.0.1                    py37_0
python                    3.7.4                h5263a28_0
python-dateutil           2.8.0                    py37_0
pytz                      2019.2                     py_0
pyyaml                    5.1.2            py37he774522_0
pyzmq                     18.1.0           py37ha925a31_0
qt                        5.9.7            vc14h73c81de_0
scikit-learn              0.21.2           py37h6288b17_0
scipy                     1.3.1            py37h29ff71c_0
setuptools                41.2.0                   pypi_0    pypi
sip                       4.19.8           py37h6538335_0
six                       1.12.0                   pypi_0    pypi
spyder-kernels            0.5.1                    py37_0
sqlite                    3.29.0               he774522_0
sympy                     1.4                      py37_0
tb-nightly                1.15.0a20190806          pypi_0    pypi
tensorboard               1.14.0           py37he3c9ec2_0
tensorflow                1.14.0          mkl_py37h7908ca0_0
tensorflow-base           1.14.0          mkl_py37ha978198_0
tensorflow-estimator      1.14.0                     py_0
termcolor                 1.1.0                    pypi_0    pypi
tornado                   6.0.3            py37he774522_0
traitlets                 4.3.2                    py37_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_0
wcwidth                   0.1.7                    py37_0
werkzeug                  0.15.6                   pypi_0    pypi
wheel                     0.33.6                   pypi_0    pypi
wincertstore              0.2                      py37_0
wrapt                     1.11.2           py37he774522_0
yaml                      0.1.7                hc54c509_2
zeromq                    4.3.1                h33f27b4_3
zipp                      0.5.2                      py_0
zlib                      1.2.11               h62dcd97_3

Upvotes: 1

Views: 424

Answers (1)

Mirko Piccolo
Mirko Piccolo

Reputation: 319

Installing spyder again inside the environment was the solution.

Upvotes: 1

Related Questions