0
votes

I have created environment for tensorflow but when I am importing tensorflow as tf in anaconda prompt it is running I guess and showing:

(base) C:\Users\Administrator>activate env
(env) C:\Users\Administrator>python
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2019-06-18 18:27:56.390819: I tensorflow/core/common_runtime/process_util.cc:71] Creating new thread pool with default inter op setting: 4. Tune using inter_op_parallelism_threads for best performance.
>>> print(sess.run(hello))
b'Hello, TensorFlow!'

But in spyder/Jupyter when I am running:

import tensorflow as tf

it is showing me error as:

n [2]: runfile('C:/Users/Administrator/.spyder-py3/temp.py', wdir='C:/Users/Administrator/.spyder-py3') Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Administrator/.spyder-py3/temp.py', wdir='C:/Users/Administrator/.spyder-py3')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Administrator/.spyder-py3/temp.py", line 1, in import tensorflow as tf

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow__init__.py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python__init__.py", line 49, in from tensorflow.python import pywrap_tensorflow

File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in raise ImportError(msg)

ImportError: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\ProgramData\Anaconda3\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:\ProgramData\Anaconda3\lib\imp.py", line 242, in load_module return load_dynamic(name, filename, file) File "C:\ProgramData\Anaconda3\lib\imp.py", line 342, in load_dynamic return _load(spec) ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

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.

How can I proceed further.

1
And spyder/Jupyter is also run using the Anaconda prompt?AntoineP
In what environment do you run the code when you use Spyder/Jupyter? You should properly activate env & launch Spyder OR install Spyder to env with tensorflow OR specify desired python interpreter in Spyder settings.Poolka
Configure spyder to use envAmartya Gaur
Now I created an environment and install everything in that. Everything is going great now. Thanks a ton!umesh pant

1 Answers

0
votes

(Spyder maintainer here) This problem is fixed in our latest version (3.3.4 in June 2019). Please update by running the following command in the Anaconda Prompt:

conda update spyder