setuptools icon indicating copy to clipboard operation
setuptools copied to clipboard

[BUG] Mac OS 14.2.1 setup.py install failed

Open mrocker opened this issue 1 year ago • 1 comments

setuptools version

setuptools==69.0.3

Python version

Python 3.9

OS

Mac OS 14.2.1

Additional environment information

pip==23.3.2

Description

try to install using: pip install -e . but failed.

My system path is: ['', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python39.zip', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/lib-dynload', '/Users/nick.cheng/Library/Python/3.9/lib/python/site-packages', '/Users/nick.cheng/Documents/WorkSpace/llama_index', '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages']

but setuptools cannot find the right path

===Log=== Checking .pth file support in /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages /Library/Developer/CommandLineTools/usr/bin/python3 -E -c pass TEST FAILED: /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages does NOT support .pth files bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.

Expected behavior

install into '/Users/nick.cheng/Library/Python/3.9/lib/python/site-packages'

How to Reproduce

git clone https://github.com/geekan/MetaGPT.git cd /your/path/to/MetaGPT pip install -e .

Output

    Checking .pth file support in /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages
    /Library/Developer/CommandLineTools/usr/bin/python3 -E -c pass
    TEST FAILED: /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages does NOT support .pth files
    bad install directory or PYTHONPATH

    You are attempting to install a package to a directory that is not
    on PYTHONPATH and which Python does not read ".pth" files from.  The
    installation directory you specified (via --install-dir, --prefix, or
    the distutils default setting) was:

        /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages

    and your PYTHONPATH environment variable currently contains:

        ''

    Here are some of your options for correcting the problem:

    * You can choose a different installation directory, i.e., one that is
      on PYTHONPATH or supports .pth files

    * You can add the installation directory to the PYTHONPATH environment
      variable.  (It must then also be on PYTHONPATH whenever you run
      Python and want to use the package(s) you are installing.)

    * You can set up the installation directory to support ".pth" files by
      using one of the approaches described here:

      https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations


    Please make the appropriate changes for your system and try again.

mrocker avatar Dec 26 '23 02:12 mrocker

Hi @mrocker, it seems that the installation of Python that you have in your machine, does not recognise /Users/nick.cheng/Library/Python/3.9/lib/python3.9/site-packages as the correct installation path.

There might be a series of reasons for that, but I think that the first thing to be tried is to run

pip install --use-pep517 -e .

instead of simply pip install -e .

Does that work for you?

This happens because years ago there was a change in the Python ecosystem and setuptools decided to focus on only building packages; letting pip handle the installation part. As such, it was required for package developers to some implement changes (e.g. stop relying on setuptools' install command, because setuptools is no longer used for that) and explicitly opt into this new model - by adding a pyproject.toml file to their project. If the package does not have this file pip will still try to use setuptools under the hood. You can force pip opt into the "new" behaviour[^1] using the --use-pep517 flag.

The problem in using setuptools for the installation part is that this code path has been deprecated for a long time, and works in the "best effort mode". Therefore some edge cases might fail.

[^1]: This behaviour is not actually new... it is several years old now and has been standardised a while ago.

abravalheri avatar Jan 03 '24 11:01 abravalheri