我正在尝试实现 TCP 服务器并使用 python 脚本。所以我server.py
在我的桌面上创建了一个并导入了以下模块:
from twisted.internet.protocol import Factory,Protocol
那时它已经失败了,因为如果我运行:python server.py
,我会得到以下输出:
Traceback (most recent call last):
File "server.py", line 4, in <module>
from twisted.internet.protocol import Factory,Protocol
ImportError: No module named twisted.internet.protocol
我还sys.path
用来打印我的 Python 目录并得到以下输出:
['/Users/Alfred/Desktop',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
'/Library/Python/2.7/site-packages']
我的 python 设置可能出了什么问题?
是因为我的账户特权吗?我在这台机器上以管理员身份登录。