Solved: import from parent directory in python setup


The main problem is that does not allow you to import modules from a parent directory.


from setuptools import setup, find_packages

      description='My package',
      author='My Name',
      packages=find_packages(),  # include all packages under src directory

This code is setting up a Python package. The first line imports the setup and find_packages functions from the setuptools module. The setup function is used to configure the package. The name, version, description, url, author, author_email, and license arguments are all required. The packages argument tells setup which packages to include in the package. In this case, it includes all packages under the src directory.


import is a keyword in Python that allows you to load modules from a file. When you import a module, the module’s definitions and functions are made available to the current scope.

parent directory

A parent directory is a directory that is above the current working directory. In Python, the parent directory is always the root directory.

Related posts:

Leave a Comment