0

I'm looking into making a script callable from the terminal using entry_points/console_scripts in the setup.py. So far when I used the editable install all works well. Installing like this:

 % pip3 install -e /<path>

I can call the script by typing the name "checky" directly into the terminal with no issues.

However, when I'm now trying to install it "for real" with the following:

% pip3 install /<path>

The installation works with no issues but when I now try to call the script using "checky" it looks like it's trying to run it with python 2.7. I get the following errors:

*Traceback (most recent call last):
  File "/usr/local/bin/checky", line 11, in <module>
    load_entry_point('checky==1.0.1a1', 'console_scripts', 'checky')()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 2440, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named checky*

Here is my setup.py:

setup(
    name='checky',
    version=find_version("files", "__init__.py"),
    python_requires='>=3.10',
    author='****',
    author_email='****',
    description="***",
    packages=find_packages(),
    entry_points={
        'console_scripts': [
            'checky = checky:main',
        ]
    },
)

I'm running macOS 12.1

Anyone know what I'm doing wrong? Or could anyone at least point me in the right direction on where to look for a solutions? I'm lost..

Regards, Anton


EDIT 1
After upgrading to macOS 12.3 I no longer get the issue with default python 2.7. If anyone has a solution to this that doesn't require upgrading to macOS 12.3 (getting rid of 2.7), please feel free to share.

Anyway, now we got some path issues.

After running the pip3 install command and calling "checky" I get this error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.10/bin/checky", line 5, in <module>
    from checky import main
ModuleNotFoundError: No module named 'checky'

Anything wrong in my setup.py?

5
  • From what I recall, Python 2 has been removed starting macOS 12.3 and is the default up to that version. I think you may just lack a shebang then, whether you specified python3.10 in your setup file or not. Commented Apr 25, 2022 at 14:51
  • @DasFranck I've tried adding #!/usr/bin/env python3 to checky.py Did not make a difference :/ Commented Apr 25, 2022 at 14:58
  • console_scripts should take care of the shebang in check.py, I meant adding #!/usr/bin/env python3 in your setup.py Commented Apr 25, 2022 at 15:07
  • @DasFranck Thanks for taking the time mate. However, I tried adding it to the setup.py. Same error Commented Apr 25, 2022 at 15:21
  • As Python2 is deprecated since 2 years, my recommendation would be to simply update your computer to macOS 12.3 so you don't encounter the issue again. I know that this doesn't really solve the problem per se but very few users still bother with Python2. Commented Apr 25, 2022 at 15:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.