Closed gabriel-roth closed 6 months ago
@gabriel-roth Could it be related to this?
Otherwise, what do you see as a result of running:
pip show python-snappy
I don't think so — the output from the pip show
command is
Name: python-snappy
Version: 0.7.1
Summary: Python library for the snappy compression library from Google
Home-page: http://github.com/intake/python-snappy
Author: Andres Moreira
Author-email: andres@andresmoreira.com
License: BSD
Location: /opt/homebrew/lib/python3.11/site-packages
Requires: cramjam
Required-by:
@gabriel-roth That looks good.
Let's try something else in the shell:
/usr/bin/env python
>>> import snappy
>>> dir(snappy)
what does this output?
['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__']
@gabriel-roth Hmm, that looks less good.
Can you try typing
>>> snappy.__file__
and then paste the contents the file said path points towards?
Weirdly, that command has no output.
(Many thanks for your time and attention here btw.)
@gabriel-roth How about snappy.__path__
?
That outputs _NamespacePath(['/opt/homebrew/Cellar/snappy'])
At that path, there's a folder (snappy
) that contains another folder (1.1.10
) which contains a couple more folders (include
and lib
) and various readme-type files.
Odd; since that seems like a non-Python folder. It's the contents of brew snappy which is a binary and dylib.
You might check two things:
>>> import sys
>>> print(sys.path)
and also the content of
/opt/homebrew/lib/python3.11/site-packages/snappy/
The first command returns:
['', '/Users/gabrielroth', '/opt/homebrew/Cellar/snappy', '/opt/homebrew/Cellar', '/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python312.zip', '/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12', '/opt/homebrew/Cellar/python@3.12/3.12.2_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/lib-dynload', '/opt/homebrew/lib/python3.12/site-packages']
The folder at that path contains a folder called __pycache__
and four files: snappy.py
, snappy_formats.py
, __main__.py
, and __init__.py
I notice that your path contains lots of Python 3.12 whereas your pip pointed towards Python 3.11. What does this say?
/usr/bin/env python --version
The output is Python 3.12.2
. (I had to use python3
instead of python
.)
I assume that means snappy is installed in Python 3.11? Is there a (reasonably) simple way to fix this?
Two more questions:
/usr/bin/env python --version
give you an error?spotifyfolders
?Yes, asking for python --version
gives me a env: python: No such file or directory
error.
I typically run spotifyfolders
from Keyboard Maestro as part of a macro that does some other stuff, but for testing purposes I've got the folders.py
file open in BBEdit and I'm using the Run command. I now realize that at some point I changed the shebang line at the top from #!/usr/bin/env python
to #!/usr/bin/env python3
.
Ok, in that case try this:
/usr/bin/env python3 -m pip install python-snappy
That gives me:
**error: externally-managed-environment**
× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
xyz, where xyz is the package you are trying to
install.
If you wish to install a non-brew-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip.
If you wish to install a non-brew packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Oh, I see... did you recently upgraded to a newer Apple computer?
In that case, I have two ideas:
#!/usr/bin/env python3.11
Yes! Changing the shebang as you suggested works. Thanks so much for going down this rabbit hole with me, and for this extremely useful script.
I've installed python-snappy using Homebrew but now I'm getting this error:
AttributeError: module 'snappy' has no attribute 'uncompress'
Any idea what the issue could be?