python - Python TensorFlow
问题描述
我在安装 Tensorflow 模块时遇到问题,我已经完成了研究,但我无法在线找到解决方案。我只运行 tensorflow 示例代码。
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')
这是输出:
FileNotFoundError Traceback (most recent call last)
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in <module>()
1352 try:
-> 1353 fontManager = json_load(_fmcache)
1354 if (not hasattr(fontManager, '_version') or
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in json_load(filename)
887 """
--> 888 with open(filename, 'r') as fh:
889 return json.load(fh, object_hook=_json_decode)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Mestre\\.matplotlib\\fontlist-v300.json'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-1-1e9eee4e6961> in <module>()
10 from collections import defaultdict
11 from io import StringIO
---> 12 from matplotlib import pyplot as plt
13 from PIL import Image
14
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\pyplot.py in <module>()
30 from cycler import cycler
31 import matplotlib
---> 32 import matplotlib.colorbar
33 import matplotlib.image
34 from matplotlib import rcsetup, style
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\colorbar.py in <module>()
30 import matplotlib.collections as collections
31 import matplotlib.colors as colors
---> 32 import matplotlib.contour as contour
33 import matplotlib.cm as cm
34 import matplotlib.gridspec as gridspec
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\contour.py in <module>()
16 import matplotlib.colors as mcolors
17 import matplotlib.collections as mcoll
---> 18 import matplotlib.font_manager as font_manager
19 import matplotlib.text as text
20 import matplotlib.cbook as cbook
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in <module>()
1361 raise
1362 except Exception:
-> 1363 _rebuild()
1364 else:
1365 _rebuild()
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in _rebuild()
1342 global fontManager
1343
-> 1344 fontManager = FontManager()
1345
1346 if _fmcache:
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in __init__(self, size, weight)
976 self.defaultFont = {}
977
--> 978 ttffiles = findSystemFonts(paths) + findSystemFonts()
979 self.defaultFont['ttf'] = next(
980 (fname for fname in ttffiles
c:\users\mestre\appdata\local\programs\python\python35\lib\site-packages\matplotlib\font_manager.py in findSystemFonts(fontpaths, fontext)
262 fontpaths = [win32FontDirectory()]
263 # now get all installed fonts directly...
--> 264 fontfiles.update(win32InstalledFonts(fontext=fontext))
265 else:
266 fontpaths = X11FontDirectories
TypeError: 'NoneType' object is not iterable
matplotlib 似乎有问题,但我已经安装了该模块,并编译了 protoc 文件,这是我第三次尝试安装 tensorflow 但没有成功。感谢所有会回复的小伙子再次感谢,宝拉
解决方案
这是 matplotlib 中的一个错误。在lib/matplotlib/font_manager.py
您需要将win32InstalledFonts
功能更改为return []
而不是return None
.
记录在这里: https ://github.com/matplotlib/matplotlib/pull/12174/files
推荐阅读
- vim - 为什么 Vim 会认为一个文件不是只读的?
- arrays - 为什么我不能使用字节或文件作为有效负载调用 sagemaker 端点
- node.js - SurveyMonkey API 使用 NodeJS 创建调查
- c# - 基于在 C# 中选中的单选按钮自动填充文本框?
- c++ - C++ 并发队列按引用或值推送
- php - 将数组转换为普通数组
- javascript - TypeScript 参数定义覆盖
- xml - 在 Android Studio 上将 apk 安装到虚拟设备时出错
- azure - 功能不像我的控制台应用程序那样读取服务总线队列
- reactjs - Webpack 4 错误 - 模块解析失败:意外字符“@”