>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
import numpy as np
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name 'multiarray'
安装matplotlib
#conda install matplotlib
然后出现:
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\envs\tensorflow\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:\Anaconda3\envs\tensorflow\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda3\envs\tensorflow\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: 找不到指定的模块。
为了省事, 直接conda remove tensorflow 这个环境。 重新装。
conda create -n tensorflow pip python=3.6
conda activate tensorflow
python -m pip install html5lib bleach ipykernel
python -m pip install --ignore-installed --upgrade pip setuptools
出错:
No module named 'pip._internal'
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall
安装TensorFlow
python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
或
python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow-gpu
还是不行。
按以下方法重新安装,成功
pip uninstall numpy;pip uninstall scipy;pip uninstall matplotlib;pip uninstall scikit-learn
在下面的网站中找到对应的包,如果是python3.5.X就是cp35系列的,电脑是多少位的一定下载对应版本
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
http://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorFlow
找到安装python(此处也为Anaconda对用的scipyts)的目录下的scipyts文件,在这个文件里安装相应的whl包
比如指令为 cd C:/xxx/xxx/scipyts,然后在这里用指令 pip install D:/xxx/xxx/xxx.whl
------------------------------------------------
过了一天,发现环境又坏了, 重新装:
conda remove --name tensorflow --allco
conda create --name tensorflow python=3.6
conda activate tensorflow
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall
python -m pip install html5lib bleach ipykernel
python -m pip install --ignore-installed --upgrade pip setuptools
python -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
python
import tensorflow as tf
c=tf.constant("A.C., you have done a good job")
s=tf.Session()
s.run(c)
运行,通过。
测试一下mnist,从http://yann.lecun.com/exdb/mnist把四个测试/验证数据集文件下载到D:\AI\dataset\mnist
找到mnist_with_summaries.py 所在目录
一般在Anaconda3\Lib\site-packages\tensorflow\examples\tutorials\mnist目录下
python mnist_with_summaries.py --log_dir=.\log --data_dir=d:\AI\dataset\mnist
训练完后,执行:
tensorboard --logdir=.\log
提示:TensorBoard 1.10.0 at http://你的IP:6006 (Press CTRL+C to quit)
打开浏览器输入地址就可以看到结果了