A story about a python beginner stuck with No module named'http.server'

environment

code

http.py


# -*- coding: utf-8 -*-

import http.server

server_address = ("", 8000)
handler_class = http.server.CGIHTTPRequestHandler #1 Set handler
server = http.server.HTTPServer(server_address, handler_class)
server.serve_forever()

As mentioned above, when setting up an http server that listens on localhost 8000, I was worried because the following message was output, so Tips.

Error message

error_log


C:\Python34\python.exe C:/Users/xxx/PycharmProjects/untitled/http.py
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/xxx/PycharmProjects/untitled/http.py", line 3, in <module>
    import http.server
  File "C:\Users\xxx\PycharmProjects\untitled\http.py", line 3, in <module>
    import http.server
ImportError: No module named 'http.server'; 'http' is not a package

Cause

I changed the file name to http.py, so changing it to test.py etc. will work.

This time it is http, but depending on the external module to be imported, Please note that other file names may also be out.

Recommended Posts

A story about a python beginner stuck with No module named'http.server'
A story about a Python beginner who was about to be crushed by ModuleNotFoundError: No module named'tweepy'
[Python3] A story stuck with time zone conversion
A story about making 3D space recognition with Python
A story about making Hanon-like sheet music with Python
A story about trying a (Golang +) Python monorepo with Bazel
A story about an amateur making a breakout with python (kivy) ①
A story about adding a REST API to a daemon made with Python
A story about developing a soft type with Firestore + Python + OpenAPI + Typescript
The story of making a module that skips mail with python
A note where a Python beginner got stuck
A story about machine learning with Kyasuket
A story about Python pop and append
ModuleNotFoundError in Python: No module named story
A story about a beginner making a VTuber notification bot from scratch in Python
I get a Python No module named'encodings' error with the aws command
Error when installing a module with Python pip
A story about implementing a login screen with django
A story about running Python on PHP on Heroku
A story about modifying Python and adding functions
A story about a programming beginner who made a business efficiency map application with GeoDjango
Automatic Zakuzaku, Bitcoin. A story about a Python beginner making a coin check 1-minute chart
Create a Python module
A story about using Resona's software token with 1Password
A story about how theano was moved with TSUBAME 2.0
A memo about building a Django (Python) application with Docker
A story about a Linux beginner passing LPIC101 in a week
A story about a Linux beginner putting Linux on a Windows tablet
A story stuck with Memory Error and No space left on device on AWS EC2
A story about a Python beginner trying to get Google search results using the API
A note about hitting the Facebook API with the Python SDK
[Python] ModuleNotFoundError: No module named'urlparse'
A story about how to specify a relative path in python.
About the Python module venv
A story about competing with a friend in Othello AI Preparation
A story about installing matplotlib using pip with an error
Stumble story with Python array
A memorandum about correlation [Python]
[Note] A story about trying to override a class method with two underscores in Python 3 series.
A story about how to deal with the CORS problem
Machine learning A story about people who are not familiar with GBDT using GBDT in Python
A story about making a tanka by chance with Sudachi Py
A memorandum about Python mock
[Django] A story about getting stuck in a swamp trying to validate a zip with form [TDD]
Web scraping beginner with python
Create a directory with python
A little stuck with chainer
A story about trying to implement a private variable in Python.
A story about a GCP beginner building a Minecraft server on GCE
A note about [python] __debug__
A story that didn't work when I tried to log in with the Python requests module
[Python, Selenium, PhantomJS] A story when scraping a website with lazy load
A story stuck with the installation of the machine learning library JAX
The story of making a standard driver for db with python.
A story about trying to run multiple python versions (Mac edition)
Let's stop copying. Introducing flati, a module to flatten with Python
Create a compatibility judgment program with the random module of python.
[Python] What is a with statement?
Solve ABC163 A ~ C with Python
Operate a receipt printer with python
A python graphing manual with Matplotlib.