'Python cannot import name 'find_namespace_packages' from 'setuptools' package

I'm currently creating a python library and need to use the 'find_namespace_packages' from the 'setuptools' package. However python throwing out the following ImportError message whenever it runs:

ImportError: cannot import name 'find_namespace_packages' from 'setuptools'

However it has no trouble importing the other functions from 'setuptools' like 'setup' and 'find_packages'.

How do I troubleshoot it?

I have uninstalled and reinstalled 'setuptools' multiple times already and updated Spyder and Anaconda.

Also here is a sample of my code:

from setuptools import setup, find_namespace_packages

setup(

      name="sample",

      version="0.0.1",

      packages=find_namespace_packages()

      )

I am currently using Python 3.7.5 and setuptools is on version 49.6.0



Solution 1:[1]

As mentioned in the question's comments, the solution is to run

pip install -U setuptools

And afterwards retry installing all the packages, e.g.

pip install -e .

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Razvan Vacaru