Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broken on import #3

Closed
bryanwhiting opened this issue Jul 27, 2022 · 6 comments
Closed

broken on import #3

bryanwhiting opened this issue Jul 27, 2022 · 6 comments

Comments

@bryanwhiting
Copy link

bryanwhiting commented Jul 27, 2022

❯ poetry run find-campsites
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/Users/bryanwhiting/github/public/campsites/campsites/cli.py", line 12, in <module>
    from campsites.recreation_gov import (
  File "/Users/bryanwhiting/github/public/campsites/campsites/recreation_gov.py", line 9, in <module>
    from campsites.common import make_get_request
  File "/Users/bryanwhiting/github/public/campsites/campsites/common.py", line 8, in <module>
    def make_get_request(url: str, params: Optional[dict[str, str]] = None) -> Any:
TypeError: 'type' object is not subscriptable
@ggydush
Copy link
Owner

ggydush commented Jul 27, 2022

Interesting, see if it works if you try Python 3.9? See here

@bryanwhiting
Copy link
Author

whoops, I'm on 3.7.

@bryanwhiting
Copy link
Author

before seeing your comment, I replaced all dict[ elements with Dict[ and imported Dict from Typing. did the same with list[ to List[ and it seems to be working!

@bryanwhiting
Copy link
Author

bryanwhiting commented Jul 27, 2022

❯ find-campsites -c "Kirby Cove" -c "Hawk Campground" -d Friday -d Saturday
WARNING	2022-07-26 21:30:14,730	Error occurred during loading data. Trying to use cache server https://fake-useragent.herokuapp.com/browsers/0.1.11
Traceback (most recent call last):
  File "/Users/bryanwhiting/venvs/py37/lib/python3.7/site-packages/fake_useragent/utils.py", line 154, in load
    for item in get_browsers(verify_ssl=verify_ssl):
  File "/Users/bryanwhiting/venvs/py37/lib/python3.7/site-packages/fake_useragent/utils.py", line 99, in get_browsers
    html = html.split('<table class="w3-table-all notranslate">')[1]
IndexError: list index out of range
INFO	2022-07-26 21:30:16,113	Found campground: Kirby Cove (campground id: 232491)
INFO	2022-07-26 21:30:16,296	No availability found for Kirby Cove :( Trying again in 5 minutes.
INFO	2022-07-26 21:30:16,493	Found campground: Hawk Campground (campground id: 258815)
INFO	2022-07-26 21:30:16,693	No availability found for Hawk Campground :( Trying again in 5 minutes.

I'll try python 3.9 and see what happens

@ggydush
Copy link
Owner

ggydush commented Jul 27, 2022

I think that error can be ignored (it eventually finds a user agent). Looks like fake-useragent is broken :rip:

@bryanwhiting
Copy link
Author

❯   find-campsites -c "Kirby Cove" -c "Hawk Campground" -d Friday -d Saturday
INFO	2022-07-26 21:49:30,239	Found campground: Kirby Cove (campground id: 232491)
INFO	2022-07-26 21:49:30,406	No availability found for Kirby Cove :( Trying again in 5 minutes.
INFO	2022-07-26 21:49:30,590	Found campground: Hawk Campground (campground id: 258815)
INFO	2022-07-26 21:49:30,764	No availability found for Hawk Campground :( Trying again in 5 minutes.

no errors with python 3.9.

For anyone else struggling in the future:

  1. install python 3.9 here: https://www.python.org/downloads/release/python-390/
  2. install pip https://phoenixnap.com/kb/install-pip-mac
  3. create virtual enviroment: `cd path/to/downloaded/campsites; python3 -m venv campsites3.9venv
  4. install poetry: pip3 install poetry
  5. install the campsites package: poetry install

Then test as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants