MacHu-GWU / uszipcode-project

USA zipcode programmable database, includes up-to-date census and geometry information.
MIT License
231 stars 49 forks source link

Error: 'ZipCodeSearch' object has no attribute 'ses' #58

Open cdonner opened 2 years ago

cdonner commented 2 years ago

Describe the problem

Getting this error and the docker container crashes when I include uszipcode 1.0.1:

 File "/usr/local/lib/python3.10/site-packages/uszipcode/search.py", line 195, in __del__
   if self.ses:
AttributeError: 'ZipCodeSearch' object has no attribute 'ses'

When I pin the version to uszipcode==0.2.6, I can include the module.

MacHu-GWU commented 2 years ago

What do you mean by docker container? Could you provide more information about the runtime information? Also the sample code to reproduce this problem?

cdonner commented 2 years ago

Sure, will try to isolate it and if I can do that I will post the code.

On Jan 16, 2022 9:21 PM, Sanhe @.***> wrote:

What do you mean by docker container? Could you provide more information about the runtime information? Also the sample code to reproduce this problem?

cdonner commented 2 years ago

This seems to be pretty easy to recreate:

root@1ce1e9d1a1e5:/app# pip install uszipcode==1.0.1 Collecting uszipcode==1.0.1 Downloading uszipcode-1.0.1-py2.py3-none-any.whl (35 kB) Requirement already satisfied: requests in /usr/local/lib/python3.10/site-packages (from uszipcode==1.0.1) (2.27.1) Requirement already satisfied: attrs in /usr/local/lib/python3.10/site-packages (from uszipcode==1.0.1) (21.2.0) Collecting haversine>=2.5.0 Downloading haversine-2.5.1-py2.py3-none-any.whl (6.1 kB) Requirement already satisfied: pathlib-mate in /usr/local/lib/python3.10/site-packages (from uszipcode==1.0.1) (1.0.1) Collecting sqlalchemy-mate>=1.4.28.3 Downloading sqlalchemy_mate-1.4.28.3-py2.py3-none-any.whl (76 kB) |████████████████████████████████| 76 kB 3.7 MB/s Requirement already satisfied: atomicwrites in /usr/local/lib/python3.10/site-packages (from uszipcode==1.0.1) (1.4.0) Collecting fuzzywuzzy Downloading fuzzywuzzy-0.18.0-py2.py3-none-any.whl (18 kB) Requirement already satisfied: SQLAlchemy>=1.4.0 in /usr/local/lib/python3.10/site-packages (from uszipcode==1.0.1) (1.4.29) Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/site-packages (from SQLAlchemy>=1.4.0->uszipcode==1.0.1) (1.1.2) Collecting prettytable Downloading prettytable-3.0.0-py3-none-any.whl (24 kB) Requirement already satisfied: autopep8 in /usr/local/lib/python3.10/site-packages (from pathlib-mate->uszipcode==1.0.1) (1.5.7) Requirement already satisfied: six in /usr/local/lib/python3.10/site-packages (from pathlib-mate->uszipcode==1.0.1) (1.16.0) Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/site-packages (from requests->uszipcode==1.0.1) (2.0.7) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests->uszipcode==1.0.1) (1.26.7) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests->uszipcode==1.0.1) (2021.10.8) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests->uszipcode==1.0.1) (3.3) Requirement already satisfied: pycodestyle>=2.7.0 in /usr/local/lib/python3.10/site-packages (from autopep8->pathlib-mate->uszipcode==1.0.1) (2.8.0) Requirement already satisfied: toml in /usr/local/lib/python3.10/site-packages (from autopep8->pathlib-mate->uszipcode==1.0.1) (0.10.2) Requirement already satisfied: wcwidth in /usr/local/lib/python3.10/site-packages (from prettytable->sqlalchemy-mate>=1.4.28.3->uszipcode==1.0.1) (0.2.5) Installing collected packages: prettytable, sqlalchemy-mate, haversine, fuzzywuzzy, uszipcode Attempting uninstall: uszipcode Found existing installation: uszipcode 0.2.6 Uninstalling uszipcode-0.2.6: Successfully uninstalled uszipcode-0.2.6 Successfully installed fuzzywuzzy-0.18.0 haversine-2.5.1 prettytable-3.0.0 sqlalchemy-mate-1.4.28.3 uszipcode-1.0.1

root@1ce1e9d1a1e5:/app# python Python 3.10.1 (main, Dec 21 2021, 09:01:08) [GCC 10.2.1 20210110] on linux Type "help", "copyright", "credits" or "license" for more information.

import uszipcode /usr/local/lib/python3.10/site-packages/fuzzywuzzy/fuzz.py:11: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')

class ZipCodeSearch(uszipcode.SearchEngine): ... def get_state_from_zip(self, zipcode): ... return self.by_zipcode(zipcode).state

zipcode_search = ZipCodeSearch(simple_zipcode=True) Exception ignored in: <function SearchEngine.del at 0x7fc7fefead40> Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/uszipcode/search.py", line 195, in del if self.ses: AttributeError: 'ZipCodeSearch' object has no attribute 'ses' Traceback (most recent call last): File "", line 1, in TypeError: SearchEngine.init() got an unexpected keyword argument 'simple_zipcode'

jdimmerman commented 2 years ago

@MacHu-GWU We are seeing this with the following runtime.

Base Image: official python image with tag python:3.10.1 - https://hub.docker.com/_/python

root@bc285f05978a:/app# cat /proc/version
Linux version 5.10.47-linuxkit (root@057f9c84915b) (gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, GNU ld (GNU Binutils) 2.35.2) #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021
root@bc285f05978a:/app# uname -a
Linux bc285f05978a 5.10.47-linuxkit #1 SMP PREEMPT Sat Jul 3 21:50:16 UTC 2021 aarch64 GNU/Linux
root@bc285f05978a:/app# cat /etc/issue
Debian GNU/Linux 11 \n \l
MacHu-GWU commented 2 years ago

It is not tested in 3.10, see https://github.com/MacHu-GWU/uszipcode-project/actions/runs/1661151266

let me test it in 3.10 and get back to you

camflan commented 2 years ago

I'm seeing this issue on 3.9.12

AttributeError: 'SearchEngine' object has no attribute 'ses'
.Exception ignored in: <function SearchEngine.__del__ at 0xffff918f5a60>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/uszipcode/search.py", line 195, in __del__
    if self.ses:
AttributeError: 'SearchEngine' object has no attribute 'ses'
        "uszipcode": {
            "hashes": [
                "sha256:19bd1ee160e96544fbeefb624540ce342ae139462cce5465ae1dff6819cdbedc",
                "sha256:c1bc2e0e47f4f4446447b6be205e76943f7978a4dcd651d4059c78002634cabb"
            ],
            "index": "pypi",
            "version": "==1.0.1"
        },
stajdini commented 4 months ago

I am experiencing the same thing on Python 3.9: "AttributeError: 'SearchEngine' object has no attribute 'ses'"

My code is:

from uszipcode.search import SearchEngine zipsearch = SearchEngine(SearchEngine.SimpleOrComprehensiveArgEnum.comprehensive)

It was previously working fine. I had some issues with numpy and numba version incompatibility. I changed those versions and fixed that issue just to encounter this error. Not sure if the error is related to chaning numpy and numba but my code was working well previously so I'm confused.