Absolute imports in python not working, relative imports work

Since it’s not shown, I have to assume you’re running python a/foo.py, this puts the directory of the script (‘a’) on the beginning of sys.path when in reality you want the current directory on the beginning of sys.path. You should instead run python -m a.foo which will correctly initialize the sys.path roots for your project … Read more

“ImportError: No module named” when trying to run Python script

This issue arises due to the ways in which the command line IPython interpreter uses your current path vs. the way a separate process does (be it an IPython notebook, external process, etc). IPython will look for modules to import that are not only found in your sys.path, but also on your current working directory. … Read more

Unable to import sqlite3 using Anaconda Python

I got this working on windows by downloading: the sqlite3 dll (find your system version) And placing it into the folder: C:\Users\YOURUSER\Anaconda3\DLLs (Depending on how you installed Anaconda, this may have to be placed into the following folder: C:\ProgramData\Anaconda3\DLLs) According to @alireza-taghdisian, you can locate the exact path of your conda environments (where you need … Read more

ImportError: No Module Named bs4 (BeautifulSoup)

Activate the virtualenv, and then install BeautifulSoup4: $ pip install BeautifulSoup4 When you installed bs4 with easy_install, you installed it system-wide. So your system python can import it, but not your virtualenv python. If you do not need bs4 to be installed in your system python path, uninstall it and keep it in your virtualenv. … Read more

DLL load failed when importing PyQt5

It is because of missing Python3.dll (stub dll, that re-exports Python3x.dll functions, so that one version of extension can work for multiple versions of python). If your Python distro doesn’t bundle python3.dll, you can try one from WinPython (https://winpython.github.io/). At least the 2017/04/01 versions should have it. 1) Download WinPython (‘Zero’ version suffices; must be … Read more

Attempted relative import with no known parent package

Apparently, box_utils.py isn’t part of a package. You still can import functions defined in this file, but only if the python script that tries to import these functions lives in the same directory as box_utils.py, see this answer. Nota bene: In my case, I stumbled upon this error with an import statement with one period, … Read more