Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Unable to install uszipcode
-
Have you tried
from uszipcode.search import SearchEngine
Or import uszipcode.search?
Also, did sqlalchemy install (is it in site-packages-3)? I noticed that is a dependency, which has some non pure python.
-
@djl I noticed that in init, they try/except the real import errors that are occuring:
try: from .search import ( SearchEngine, SimpleZipcode, Zipcode, ZipcodeType, SORT_BY_DIST, ) except Exception as e: # pragma: no cover print(e)
So, try
import uszipcode.searchAnd report back on the exception. My guess is sqlalchemy.
-
>>> import uszipcode.search Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/search.py", line 16, in <module> from .db import ( File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/db.py", line 18, in <module> from pathlib_mate import Path ModuleNotFoundError: No module named 'pathlib_mate' >>> from uszipcode.search import SearchEngine Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/search.py", line 16, in <module> from .db import ( File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/db.py", line 18, in <module> from pathlib_mate import Path ModuleNotFoundError: No module named 'pathlib_mate'``` SQLAlchemy installed, sort of... EAB0EA45C0A1/tmp//SQLAlchemy-1.2.17.tar.gz (5670715 bytes) 5670715 [100.00%] Extracting archive file ... Archive extracted. Running setup file ... WARNING: Extension modules are skipped: [<__main__.OmniClass object at 0x10d4be940>, <__main__.OmniClass object at 0x10d4be080>, <__main__.OmniClass object at 0x10d4be128>] Package installed: SQLAlchemy [~/Documents]$ But after that -- same failure to import SearchEngine And after installing pathlib_mate: >>> import uszipcode.search Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/search.py", line 16, in <module> from .db import ( File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/db.py", line 18, in <module> from pathlib_mate import Path ImportError: cannot import name 'Path' This is not for the faint of heart
-
That jerk seems to love hiding exceptions in all his projects ;).
Try
import pathlib_mate.pathlib2And see what squawks next
-
import pathlib_mate.pathlib2
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/pathlib_mate/pathlib2.py", line 1203, in <module>
from .mate_tool_box import ToolBox
File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/pathlib_mate/mate_tool_box.py", line 6, in <module>
import autopep8
ModuleNotFoundError: No module named 'autopep8'So I installed autopep8 and tried again:
import pathlib_mate.pathlib2
No exceptions there. But going back to the beginning, still can't import 'Path'
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/zipcode.py", line 4, in <module>
import uszipcode.search
File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/search.py", line 16, in <module>
from .db import (
File "/private/var/mobile/Containers/Shared/AppGroup/33F42B57-E4B9-4767-9D62-5D195D377333/Pythonista3/Documents/site-packages-3/uszipcode/db.py", line 18, in <module>
from pathlib_mate import Path
ImportError: cannot import name 'Path' -
How about
from pathlib_mate.pathlib2 import Path
You might need to force quit pythonista and try again. If pathlib2 imported successfully, it should have Path.
-
After rebooting the iPad, that actually worked!! Amazing! Although I notice one of my other well functioning scripts stopped working. Is that because all of the newly installed modules somehow mess up previously working ones?
-
@JonB
Now everything is hunky-dory. Thanks for your help, Jon. I would have given up long ago. -
Could be... You'd have to look at the tracebacks to see what is failing. Check site-packages-3 and make sure you don't have any modules elsewhere named the same as one of the ones in the top level site-packages-3.
-
my question is bellow
Cannot import module 'scripts.test': cannot import name 'ExtendedBase' from 'uszipcode.pkg.sqlalchemy_mate'
Why is this -
Can you please post the full traceback?
uszipcode loves to try to import modules, then simply catch the exceptions and pass without error, making debugging it super annoying.
It appears you must have sqlalchemy installed in order to pass that import. Try installing sqlalchemy (see discussion above -- I don't think it will actually succeed, but there are just certain files that are needed to get past this specific error)
-
I try to install SQLAlchemy, it says I have already installed it
pip3 install SQLAlchemy Requirement already satisfied: SQLAlchemy in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (1.4.4) Requirement already satisfied: greenlet!=0.4.17 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from SQLAlchemy) (0.4.16)
the full Traceback
cannot import name 'ExtendedBase' from 'uszipcode.pkg.sqlalchemy_mate' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/uszipcode/pkg/sqlalchemy_mate/__init__.py) Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django_extensions/management/commands/runscript.py", line 176, in my_import t = importlib.import_module(full_module_path) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 783, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Users/lin/eano/scripts/test.py", line 2, in <module> from uszipcode import search File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/uszipcode/search.py", line 22, in <module> from .model import SimpleZipcode, Zipcode, ZipcodeType File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/uszipcode/model.py", line 15, in <module> from .pkg.sqlalchemy_mate import ExtendedBase ImportError: cannot import name 'ExtendedBase' from 'uszipcode.pkg.sqlalchemy_mate' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/uszipcode/pkg/sqlalchemy_mate/__init__.py) Cannot import module 'scripts.test': cannot import name 'ExtendedBase' from 'uszipcode.pkg.sqlalchemy_mate' (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/uszipcode/pkg/sqlalchemy_mate/__init__.py).
-
Do you have MSA Zip code mapping data?
-
Ok, the problem is likely one of the imports from extended_declarative_base.
Try each of these in the console, and see which breaks.from sqlalchemy.orm import sessionmaker from sqlalchemy.orm.session import Session from sqlalchemy.engine.base import Engine from sqlalchemy.exc import IntegrityError from sqlalchemy.orm.exc import FlushError from sqlalchemy.inspection import inspect
-
Can be imported normally
-
@lin said:
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/...
Umm, what device and app are you running this on?
This forum is for the pythonista app on iOS. This looks like you are running Mac or LInux.As a general suggestion though, you should temporarily edit
your site-packages/uszipcode/pkg/sqlalchemy_mate/init.py, and change the "pass" to "raise". One of the 3 imports in that file are failing, but because he is just hiding the exception, you can't see what fails until model.py doesn't see ExtendedBase.Also, the place to go may be the uszipcode github:
https://github.com/MacHu-GWU/uszipcode-project/issues/48
Since you are using 1.4.4 of sqlalchemy, looks like you are going to have failures.One workaround is to use
pip3 install SQLAlchemy==1.3.23or, you could implement the fixes found here
https://github.com/MacHu-GWU/uszipcode-project/pull/49/commits/73df0278f7232b789efa6621e629f8e50915bbef -
@JonB said:
pip3 install SQLAlchemy==1.3.23
It’s amazing. I installed the version you mentioned and it works. thank you very much,otherwise I would give up too