About Polygon

We are thrilled to announce that the Red Kite launchpad will now support Polygon and projects developed on this network. New IDOs of Polygon-based projects are coming to Red Kite very shortly. At Red…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Initial conditions

The other day I was asked to look at a strange bug related to launching an application. This is how $ python mymodule interpreter failed with an error ModuleNotFoundError: No module named 'http.server'; 'http' is not a package (or ImportError: cannot import name 'server' from partially initialized module 'http' — depends on how to import http.server). The problem goes away if the package is run correctly $ python -m mymodule. So, this issue can be solved this way, but I’d like to dig deeper and figure out how these 2 commands differ.

The package structure was like this:

Of course, there was no “server” attribute in the http.py file. http.server should have been imported from the standard distribution according to business logic. Below I have provided the minimum required code to reproduce the problem.

So we found out who overrides sys.path when running $ python mymodule, and at the same time, we noticed that you can run packages as zip files. That is, such an option overlaps the scope of packages from the standard distribution and site-packages.

Add a comment

Related posts:

Configuring OpenLDAP in WSO2 Identity Server 5.11.0

WSO2 Identity Server (IS) is a leading API driven, open-source Customer Identity and Access Management (CIAM) product that is easy to use and very versatile in its offering. You can right away start…

Starting with Event Sourcing in PHP

Would you like to start using Event Sourcing in PHP, however you don’t feel like you have enough knowledge? Maybe you have started demo project and the tools were to complex to make learning process…

How To Lose Weight For Teens 2023

Losing weight as a teenager can be challenging, but it is definitely possible. Here are 7 unique tips to help you shed those extra pounds and feel your best: Eat a healthy diet: The most important…