Python issue on M1? Or unrelated

Posted on
Sat May 29, 2021 8:42 am
tornado offline
User avatar
Posts: 104
Joined: Jun 30, 2014

Python issue on M1? Or unrelated

Hi everyone,

I recently updated to an M1 Mac Mini as well and migrated my existing setup over to it. Everything went swimmingly except that I can't seem to get num2words and PIL/Pillow installed on the Python instance there. I'm -> <- this close to reformatting the whole thing and/or returning the Mini as I really use both these packages.

I've poured through the forums here (especially Jay's pinned post) and googled the heck out of this but could really use some help if anyone has it. I'm not sure if this is specific to my M1 Mac or not even related but could use some advice.

Code: Select all
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% which python
/usr/bin/python
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% which pip
/usr/local/bin/pip
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% pip -V
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  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)
  File "/Library/Python/2.7/site-packages/pip-21.1.1-py2.7.egg/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax


Trying to install num2words gives me a similar error:
Code: Select all
tornado@macmini:~% sudo pip install num2words
Password:
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  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)
  File "/Library/Python/2.7/site-packages/pip-21.1.1-py2.7.egg/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax


PIL's is the same.

Any help greatly appreciated.

Joe

Posted on
Sun May 30, 2021 6:14 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python issue on M1? Or unrelated

It looks like you may not be getting the ACTUAL error(s) that you're encountering. It appears to me that the traceback applies to pip while trying to output the actual error text, seeing as both attempts yield the same final error message. I'm hesitant to tell you to tear into pip's codebase in order to get to fix that error. I did find this post which seems at least tangentially related. You might do some searching around that to see if someone has posted steps to fix it. Regarding Pillow, I found some discussion that folks are having difficulty installing Matplotlib on M1 Macs because one of its dependencies is PIL/Pillow, and one of Pillow's dependencies isn't properly supported.

What may be the better course of action is to modify your scripts to do the necessary Pillow and num2words functions in a Python3 script and call that code externally from your Indigo Python 2.7 script(s). There has been recent discussion of running Python 3 scripts on this forum.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun May 30, 2021 10:52 am
tornado offline
User avatar
Posts: 104
Joined: Jun 30, 2014

Re: Python issue on M1? Or unrelated

This is super valuable information! Thank you! I've been pulling my hair out on this for too long!

Posted on
Sun May 30, 2021 12:08 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Python issue on M1? Or unrelated

My pleasure. Hope you're able to find a workable solution.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sun May 30, 2021 12:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python issue on M1? Or unrelated

Try:

Code: Select all
pip --version


I wonder if you have an old version of pip or something. Seems like it's pip that's having the issue so sorting that out might help.

Also: can someone else with an M1 Mac do that and a which:

Code: Select all
which pip


So we can see locations and versions on a working M1 Mac?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Mon May 31, 2021 7:25 pm
lalisingh offline
Posts: 166
Joined: Mar 27, 2007

Re: Python issue on M1? Or unrelated

pip --version results in pip command not found.

m1 mac mini

[url]https://www.VillageWorker.com[/url]
Extreme data analytics, Sensing, Control integration work.
Indigo • Barix • Kentix • Mobotix • Mikrotik • Apple

Posted on
Thu Jun 03, 2021 8:35 am
bschollnick2 offline
Posts: 1355
Joined: Oct 17, 2004
Location: Rochester, Ny

Re: Python issue on M1? Or unrelated

tornado wrote:
Hi everyone,

I recently updated to an M1 Mac Mini as well and migrated my existing setup over to it. Everything went swimmingly except that I can't seem to get num2words and PIL/Pillow installed on the Python instance there. I'm -> <- this close to reformatting the whole thing and/or returning the Mini as I really use both these packages.

I've poured through the forums here (especially Jay's pinned post) and googled the heck out of this but could really use some help if anyone has it. I'm not sure if this is specific to my M1 Mac or not even related but could use some advice.

Code: Select all
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% which python
/usr/bin/python
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% which pip
/usr/local/bin/pip
tornado@macmini:~/Library/Python/2.7/lib/python/site-packages% pip -V
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  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)
  File "/Library/Python/2.7/site-packages/pip-21.1.1-py2.7.egg/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax


Trying to install num2words gives me a similar error:
Code: Select all
tornado@macmini:~% sudo pip install num2words
Password:
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 11, in <module>
    load_entry_point('pip==21.1.1', 'console_scripts', 'pip')()
  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)
  File "/Library/Python/2.7/site-packages/pip-21.1.1-py2.7.egg/pip/_internal/cli/main.py", line 58
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax


PIL's is the same.


1) My understanding is that Python v2.7 is not officially supported on the M1 Macs in Native mode.

I worked with the Pillow team on getting M1 native support working, admitably as a tester. But I believe the lowest you can go is Python v2.8 for native M1 support? I can't recall what I'm running right now (Python v2.95?) with my Gallery app...?

You can use "Python -m pip --version" and that'll report it directly.

Now adays, for PIP that seems to be the recommended way of using it, to help ensure that you are using the version of pip included in the python version that you are executing... Especially when you have multiple versions of python installed on the same box.

------
My Plugins for Indigo (v4, v5, and v6) - http://bit.ly/U8XxPG

Security Script for v4 - http://bit.ly/QTgclf
for v5 - http://bit.ly/T6WBKu

Support Forum(s) - http://www.perceptiveautomation.com/userforum/viewforum.php?f=33

Posted on
Fri Jun 04, 2021 10:44 am
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python issue on M1? Or unrelated

bschollnick2 wrote:
But I believe the lowest you can go is Python v2.8 for native M1 support? I can't recall what I'm running right now (Python v2.95?) with my Gallery app...?


Python 2.7.x is the last version of Python 2. Perhaps you're thinking of Python 3?

lalisingh wrote:
pip --version results in pip command not found.

m1 mac mini


The OP apparently had pip installed so I'm unclear if he did that before posting or not. What version of Big Sur are you using?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Jun 04, 2021 1:56 pm
jay (support) offline
Site Admin
User avatar
Posts: 18219
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Python issue on M1? Or unrelated

It appears that pip isn't installed for Python 2 in Big Sur (at least on M1 Macs, probably not at all). For those having pip issues, you can try installing it via the method outlined in this stack overflow article (reproduced here for simplicity (run from terminal, and make sure that the python command is actually python 2.7.x, that's the first line below):

Code: Select all
python --version  # this will show the version, make sure it's 2.7.x
curl -O https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
python -m pip install --upgrade "pip < 21.0"


I just tried it on a non-M1 Mac mini running Big Sur, where I had already installed pip for Python 3. It worked, but note that my path still points to the Python 3 pip first. However, you can access it for Python 2.7 via the pip2 command.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests