Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Mac OS 14.2.1 setup.py install failed #4166

Open
mrocker opened this issue Dec 26, 2023 · 1 comment
Open

[BUG] Mac OS 14.2.1 setup.py install failed #4166

mrocker opened this issue Dec 26, 2023 · 1 comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status. Waiting User Feedback

Comments

@mrocker
Copy link

mrocker commented Dec 26, 2023

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 mrocker added bug Needs Triage Issues that need to be evaluated for severity and status. labels Dec 26, 2023
@abravalheri
Copy link
Contributor

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" behaviour1 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.

Footnotes

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status. Waiting User Feedback
Projects
None yet
Development

No branches or pull requests

2 participants