在python安装目录下的Scripts下,有两个文件,compile.py和usemodule.py,其中compile.py代码如下:importpy_compilepy_compile.compile('usemodule.py','usemodule.pyc')在pythonwin里...
在python安装目录下的Scripts下,有两个文件,compile.py和usemodule.py,其中compile.py代码如下:
import py_compile
py_compile.compile('usemodule.py','usemodule.pyc')
在pythonwin里面打开并运行compile.py,报错如下:
Traceback (most recent call last):
File "C:\Python32\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript
exec(codeObject, __main__.__dict__)
File "C:\Python32\Scripts\compile.py", line 9, in
py_compile.compile('usemodule.py','usemodule.pyc') #编译usemodule.py
File "C:\Python32\lib\py_compile.py", line 111, in compile
with tokenize.open(file) as f:
File "C:\Python32\lib\tokenize.py", line 346, in open
buffer = builtins.open(filename, 'rb')
IOError: [Errno 2] No such file or directory: 'usemodule.py'
但是在cmd里面,进入到Scripts目录下,运行compile.py,就没有问题。
展开