我使用Anaconda在Windows 10中安装了Python。虽然它可以import sys
但却不能import random
或import os
。请建议解决方案。
http://pastebin.com/vu3U3pNt
C:\Users\mona>conda info
Current conda install:
platform : win-64
conda version : 4.2.9
conda is private : False
conda-env version : 4.2.9
conda-build version : 2.0.2
python version : 3.5.2.final.0
requests version : 2.11.1
root environment : C:\Program Files\Anaconda3 (read only)
default environment : C:\Program Files\Anaconda3
envs directories : C:\Users\mona\.conda\envs
C:\Program Files\Anaconda3\envs
package cache : C:\Users\mona\.conda\envs\.pkgs
C:\Program Files\Anaconda3\pkgs
channel URLs : https://repo.continuum.io/pkgs/free/win-64/
https://repo.continuum.io/pkgs/free/noarch/
https://repo.continuum.io/pkgs/pro/win-64/
https://repo.continuum.io/pkgs/pro/noarch/
https://repo.continuum.io/pkgs/msys2/win-64/
https://repo.continuum.io/pkgs/msys2/noarch/
config file : None
offline mode : False
所以在renderdoc中,当我使用Python交互式shell时,它无法导入os,但是在cmd中它可以:
这是RenderDoc Python Interactive shell 2.7.4 (IronPython 2.7.4 (2.7.0.40) on .NET 4.0.30319.42000 (64-bit))
C:\Users\mona>python
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import random
我想知道有人知道为什么会这样,以及如何解决它? 这是我在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'
答案 0 :(得分:1)
通过替换这些行来修复它(安装了两个版本):
#config['py_lib_dir'] = 'C:\\Program Files\\Anaconda3\\Lib\\' # where we find the Python libraries
config['py_lib_dir'] = 'C:\\Program Files\\Anaconda2\\Lib\\'