python install wheel leads to import error

If you need to execute the setup script from another directory, ensure you are entering the project dir in the script.

from setuptools import setup

root = os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))
os.chdir(root)

# or using pathlib (Python>=3.4):
import patlib
root = pathlib.Path(__file__).parent
os.chdir(str(root))

setup(...)

Leave a Comment