Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python ImportError:没有名为random的模块_Python_Import_Window_Anaconda_Conda - Fatal编程技术网

Python ImportError:没有名为random的模块

Python ImportError:没有名为random的模块,python,import,window,anaconda,conda,Python,Import,Window,Anaconda,Conda,我已经使用Anaconda在Windows 10中安装了Python。但是,虽然它可以导入系统,但不能导入随机或导入操作系统。请提出解决方案。 因此,在renderdoc中无法导入os,但在cmd中,当我使用Python interactive shell时,它可以: 这是RenderDoc Python Interactive shell中sys.version的输出2.7.4(在.NET 4.0.30319.42000(64位)上的IronPython 2.7.4(2.7.0.40)) 我

我已经使用Anaconda在Windows 10中安装了Python。但是,虽然它可以
导入系统
,但不能
导入随机
导入操作系统
。请提出解决方案。

因此,在renderdoc中无法导入os,但在cmd中,当我使用Python interactive shell时,它可以: 这是RenderDoc Python Interactive shell中sys.version的输出
2.7.4(在.NET 4.0.30319.42000(64位)上的IronPython 2.7.4(2.7.0.40))

我想知道是否有人知道这是为什么,以及如何解决它? 以下是我在RenderDoc Python的交互式shell中看到的内容:

RenderDoc Python console, powered by IronPython 2.7.4.1000
The 'renderdoc' object is the Core class instance.
还请注意:

config = {}
config['py_lib_dir']  = 'C:\\Program Files\\Anaconda3\\Lib\\'      # where we find the Python libraries
config['save_dir']    = 'D:/gta5_extracted/' # where we store extraction results
# creates a prefixes for files and directories from logfilename
config['dir_prefix']  = lambda logFilename : ''       
config['file_prefix'] = lambda logFilename : basename(logFilename)[:-4] + '_'
import sys
print(sys.version)
sys.path.append(config['py_lib_dir'])
from os import mkdir
给出了错误:

2.7.4 (IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.42000 (64-bit))
Extracting from frame 0
  File "C:\Program Files\Anaconda3\Lib\os.py", line 407
                    yield from walk(entry.path, topdown, onerror, followlinks)

                          ^
SyntaxError: unexpected token 'from'

通过更换这些线路将其修复(已安装两个版本):


为什么不以常规的方式使用它的?我从未尝试过Anaconda。请确保python安装正确。或者重新安装它。没有理由看起来像那样。@AshrafulIslam你看到了pastebin吗?它似乎安装正确您似乎安装了适用于linux-64位的Anaconda。Anaconda3适用于Python 3,但在renderdoc中运行的Python是2.7。Python2中的“yield from”语法不正确,因此出现了错误。检查renderdoc的解释器设置并设置Python 3.5.2如果您的答案解决了问题,您可以将其检查为已验证以帮助其他人:)需要两天才能让我接受我的答案,但请确定:)
config = {}
config['py_lib_dir']  = 'C:\\Program Files\\Anaconda3\\Lib\\'      # where we find the Python libraries
config['save_dir']    = 'D:/gta5_extracted/' # where we store extraction results
# creates a prefixes for files and directories from logfilename
config['dir_prefix']  = lambda logFilename : ''       
config['file_prefix'] = lambda logFilename : basename(logFilename)[:-4] + '_'
import sys
print(sys.version)
sys.path.append(config['py_lib_dir'])
from os import mkdir
2.7.4 (IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.42000 (64-bit))
Extracting from frame 0
  File "C:\Program Files\Anaconda3\Lib\os.py", line 407
                    yield from walk(entry.path, topdown, onerror, followlinks)

                          ^
SyntaxError: unexpected token 'from'
#config['py_lib_dir']  = 'C:\\Program Files\\Anaconda3\\Lib\\'      # where we find the Python libraries
config['py_lib_dir']  = 'C:\\Program Files\\Anaconda2\\Lib\\'