Import error aftert adding site.py file to project

2019-07-29 15:29发布

问题:

After I've added site.py to top directory of my project, my application started to fail with an exception: "ImportError: No module named 'bs4'".

Before adding this file, application worked file. BeautifulSoup4 package is installed in used interpreter.

What's happening here?

回答1:

site.py shadows built-in site module.

Due to wrong site.py module being imported, paths used to search for user-installed packages are never set, therefore interpreter is unable to find bs4 module.