【发布时间】:2017-06-28 23:24:30
【问题描述】:
我正在使用 MACOSX 10.12.3 和 Python 3.52
在 python IDLE 的 bash 脚本中运行 pydoc 时遇到问题。 例如:
myFile = ‘/home/user/afile.py’
import subprocess
subprocess.run([‘pydoc’, ‘-w’, myFile])
不可避免地不会像预期的那样创建 html 文件。 另一方面,当我在终端中运行 pydoc 时
pydoc3 -w /home/user/afile.py
它总是创建想要的 html 文件。但是pydoc -w /home/user/afile.py会报错
这是因为:
- python
/home/user/afile.py包含一些 python3 样式的打印语句。即:print('blabla')而不是:print 'blabla',就像在 python2 上的情况一样。 - IDLE 中的 bash 脚本没有加载正确的 pydoc。我还要提一下,运行
subprocess.run([‘pydoc3’, ‘-w’, myFile])会产生错误,例如:
subprocess.run(['pydoc3', '-w', myFile]) 文件 "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", 第 693 行,运行中 使用 Popen(*popenargs, **kwargs) 作为进程:文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py”, 第 947 行,在 init 中 restore_signals,start_new_session)文件“/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py”, 第 1551 行,在 _execute_child 中 raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: 'pydoc3'
请问有没有人可以解决这个问题?
【问题讨论】:
标签: macos python-3.5 pydoc