python setup.py looking in the wrong directory for dependencies

Viewed 41

I'm using py2app and running my setup.py file in a local directory, which also reads a requirements.txt file for the install_required param. However, when running;

python3 setup.py py2app -A

I get the error:

File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pkg_resources/__init__.py", line 785, in resolve
    raise DistributionNotFound(req, requirers)

pkg_resources.DistributionNotFound: The 'numpy==1.22.4' distribution was not found and is required by the application

When I look for the location of numpy, it shows up in a different directory:

pip3 show numpy
Location: /usr/local/lib/python3.9/site-packages

Is there a reason why setup.py / setuptools is looking in another diirectory - how can I make it point to a different directory, with all my dependencies? Current setup.py code;

from setuptools import setup

with open('requirements.txt') as f:
    required = f.read().splitlines()

APP = ['option_pricer.py']
DATA_FILES = []
OPTIONS = {}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
    install_requires=required,
)

Another interesting thing:

python3 -m pip --version

returns

pip 20.2.3 from /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)
0 Answers
Related