我在这里{@ {3}}关注了senddex的深度学习张量流教程。
我一直遵循本教程,直到绕过这里为止:
#import tools
import gym
import random
import numpy as np
import tflearn
from tflearn.layers.core import input_data, dropout,fully_connected
from tflearn.layers.estimator import regression
from statistics import mean, median
from collections import Counter
#sets the learning rate of the algorithm
LR = 1e-3
#sets up the enviroment and resets it
env = gym.make ('CartPole-v0')
env.reset()
#creates the time goal for the algorithm to solve
goal_steps = 500
#sets the requirement for the original random games
score_requirement
#sets the number of games that are initially played
initial_games = 100
def some_random_games_first():
for episode in range (5):
env.reset()
for t in range(goal_steps):
env.render()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
break
some_random_games_first()
在我尝试运行它并得到此错误之前,代码似乎还不错:
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
==== RESTART: C:\Python Programs\Deep Learning\Deep Learning Cartpole.py ====
Traceback (most recent call last):
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python Programs\Deep Learning\Deep Learning Cartpole.py", line 5, in <module>
import tflearn
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tflearn\__init__.py", line 4, in <module>
from . import config
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tflearn\config.py", line 3, in <module>
import tensorflow as tf
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\William\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
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.
我已经花费了数小时寻找解决方案,但没有找到任何解决方案。我是深度学习和张量流领域的新手,所以请您保持简单。
谢谢, 特威兹勒
编辑:我已经安装了TFLearn,OpenAI的健身房和TensorFlow,但是“ pip install tensorflow”不起作用,所以我做了“ pip install –upgrade https://www.youtube.com/watch?v=3zeg7H6cAJw”
答案 0 :(得分:0)
我发现Python 3.7与最新版本的tensorflow不兼容,但是如果我将它与Anaconda一起安装,它将可以正常工作。