Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unable to install certain python modules

I’m trying to follow a tutorial about creating and hosting an HTTP proxy. When I try to install the modules, it fails. (SimpleHTTPServer and SocketServer)

Tutorial used: https://levelup.gitconnected.com/how-to-build-a-super-simple-http-proxy-in-python-in-just-17-lines-of-code-a1a09192be00

Output:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

When I try to run the program:

Traceback (most recent call last):
  File "simpleServer.py", line 1, in <module>
    import SocketServer
ModuleNotFoundError: No module named 'SocketServer'

>Solution :

Those are standard library’s modules as LeopardShark mentioned. You can import them directly to your code without installing them with pip.

The complete list of modules coming with standard library you can find here: https://docs.python.org/3/library/

Also, the specific modules you’re asking about were renamed in Python3:

Note The SimpleHTTPServer module has been merged into http.server in Python 3.

Based on module’s documentation: https://docs.python.org/2/library/simplehttpserver.html

Basically, you just need to do:

import http.server
import socketserver
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading