无法安装某些 python 模块
Unable to install certain python modules
我正在尝试学习有关创建和托管 HTTP 代理的教程。当我尝试安装模块时,它失败了。 (简单 HTTPServer 和 SocketServer)
输出:
pip install SimpleHTTPServer
ERROR: Could not find a version that satisfies the requirement SimpleHTTPServer (from versions: none)
ERROR: No matching distribution found for SimpleHTTPServer
pip install SocketServer
ERROR: Could not find a version that satisfies the requirement SocketServer (from versions: none)
ERROR: No matching distribution found for SocketServer
当我尝试 运行 程序时:
Traceback (most recent call last):
File "simpleServer.py", line 1, in <module>
import SocketServer
ModuleNotFoundError: No module named 'SocketServer'
如 LeopardShark 所述,这些是标准库的模块。您可以直接将它们导入到您的代码中,而无需使用 pip 安装它们。
您可以在此处找到标准库随附的完整模块列表:https://docs.python.org/3/library/
此外,您询问的特定模块已在 Python3 中重命名:
Note The SimpleHTTPServer module has been merged into http.server in Python 3.
基于模块的文档:https://docs.python.org/2/library/simplehttpserver.html
基本上,您只需要做:
import http.server
import socketserver
我正在尝试学习有关创建和托管 HTTP 代理的教程。当我尝试安装模块时,它失败了。 (简单 HTTPServer 和 SocketServer)
输出:
pip install SimpleHTTPServer
ERROR: Could not find a version that satisfies the requirement SimpleHTTPServer (from versions: none)
ERROR: No matching distribution found for SimpleHTTPServer
pip install SocketServer
ERROR: Could not find a version that satisfies the requirement SocketServer (from versions: none)
ERROR: No matching distribution found for SocketServer
当我尝试 运行 程序时:
Traceback (most recent call last):
File "simpleServer.py", line 1, in <module>
import SocketServer
ModuleNotFoundError: No module named 'SocketServer'
如 LeopardShark 所述,这些是标准库的模块。您可以直接将它们导入到您的代码中,而无需使用 pip 安装它们。
您可以在此处找到标准库随附的完整模块列表:https://docs.python.org/3/library/
此外,您询问的特定模块已在 Python3 中重命名:
Note The SimpleHTTPServer module has been merged into http.server in Python 3.
基于模块的文档:https://docs.python.org/2/library/simplehttpserver.html
基本上,您只需要做:
import http.server
import socketserver