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

Multiple Python 3.10+ issues #418

Open
clach04 opened this issue Nov 12, 2022 · 13 comments
Open

Multiple Python 3.10+ issues #418

clach04 opened this issue Nov 12, 2022 · 13 comments

Comments

@clach04
Copy link
Contributor

clach04 commented Nov 12, 2022

  1. Pillow 8.0.0 does not support Python 3.10 - EDIT see Bump pillow from 6.2.2 to 9.0.1 #415
    a. does not provide prebuilt Windows binaries
  2. tabulate (0.7.7) latest version as of 2022-11-12 does not support Python >=3.10 EDIT see Multiple Python 3.10+ issues #418 (comment)
  3. SyntaxWarning: "is" with a literal.
  4. Nose test suite - not supported (nor maintained)

Pillow

C:\Users\clach04\AppData\Local\Temp\pip-install-i85cqwbb\pillow_86813ad0d0c649aabea19ecf8728fa8d\setup.py:41: RuntimeWarning: Pillow 8.0.0 does not support
Python 3.10 and does not provide prebuilt Windows binaries. We do not recommend building from source on Windows.

workaround:

pip install pillow  # or edit requirements.txt

pillow-9.3.0 installs fine

tabulate

import error

(py310venv) C:\code\py\elodie>python elodie.py
Traceback (most recent call last):
  File "C:\code\py\elodie\elodie.py", line 32, in <module>
    from elodie.result import Result
  File "C:\code\py\elodie\elodie\result.py", line 1, in <module>
    from tabulate import tabulate
  File "C:\py310venv\lib\site-packages\tabulate.py", line 7, in <module>
    from collections import namedtuple, Iterable
ImportError: cannot import name 'Iterable' from 'collections' (C:\Pythons\Python310\lib\collections\__init__.py)

Hack to tabulate

#from collections import namedtuple, Iterable
from collections import namedtuple
try:
    from collections import Iterable
except ImportError:
    from collections.abc import Iterable

syntax warning

(py310venv) C:\code\py\elodie>python elodie.py
C:\py310venv\lib\site-packages\tabulate.py:201: SyntaxWarning: "is" with a literal. Did you mean "=="?
  if isinstance(val, (_text_type, _binary_type)) and val.strip() is "":
Usage: elodie.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  batch        Run batch() for all plugins.
  generate-db  Regenerate the hash.json database which...
  import       Import files or directories by reading their...
  update       Update a file's EXIF.
  verify

2nd hack:

    #if isinstance(val, (_text_type, _binary_type)) and val.strip() is "":
    if isinstance(val, (_text_type, _binary_type)) and val.strip() == "":

Nose

(py310venv) C:\code\py\elodie_upstream>python -m pip install -r elodie/tests/requirements.txt
Ignoring Pillow: markers 'python_version == "2.7"' don't match your environment
Collecting click==6.6
  Using cached click-6.6-py2.py3-none-any.whl (71 kB)
Collecting requests==2.20.0
  Using cached requests-2.20.0-py2.py3-none-any.whl (60 kB)
Collecting Send2Trash==1.3.0
  Using cached Send2Trash-1.3.0.tar.gz (5.6 kB)
  Preparing metadata (setup.py) ... done
Collecting future==0.16.0
  Using cached future-0.16.0.tar.gz (824 kB)
  Preparing metadata (setup.py) ... done
Collecting configparser==3.5.0
  Using cached configparser-3.5.0.tar.gz (39 kB)
  Preparing metadata (setup.py) ... done
Collecting tabulate==0.7.7
  Using cached tabulate-0.7.7-py2.py3-none-any.whl (31 kB)
Collecting Pillow==9.3
  Using cached Pillow-9.3.0-cp310-cp310-win_amd64.whl (2.5 MB)
Collecting six==1.9
  Using cached six-1.9.0-py2.py3-none-any.whl (10 kB)
Collecting flake8==2.6.2
  Using cached flake8-2.6.2-py2.py3-none-any.whl (38 kB)
Collecting mock==1.3.0
  Using cached mock-1.3.0-py2.py3-none-any.whl (56 kB)
Collecting nose==1.3.7
  Using cached nose-1.3.7-py3-none-any.whl (154 kB)
Collecting chardet<3.1.0,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting urllib3<1.25,>=1.21.1
  Using cached urllib3-1.24.3-py2.py3-none-any.whl (118 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2022.12.7-py3-none-any.whl (155 kB)
     ---------------------------------------- 155.3/155.3 KB 1.6 MB/s eta 0:00:00
Collecting idna<2.8,>=2.5
  Using cached idna-2.7-py2.py3-none-any.whl (58 kB)
Collecting pycodestyle<2.1,>=2.0
  Using cached pycodestyle-2.0.0-py2.py3-none-any.whl (42 kB)
Collecting pyflakes!=1.2.0,!=1.2.1,!=1.2.2,<1.3,>=0.8.1
  Using cached pyflakes-1.2.3-py2.py3-none-any.whl (209 kB)
Collecting mccabe<0.6,>=0.2.1
  Using cached mccabe-0.5.3-py2.py3-none-any.whl (8.5 kB)
Collecting pbr>=0.11
  Using cached pbr-5.11.0-py2.py3-none-any.whl (112 kB)
Using legacy 'setup.py install' for Send2Trash, since package 'wheel' is not installed.
Using legacy 'setup.py install' for future, since package 'wheel' is not installed.
Using legacy 'setup.py install' for configparser, since package 'wheel' is not installed.
Installing collected packages: tabulate, six, Send2Trash, pyflakes, pycodestyle, nose, mccabe, idna, future, configparser, click, chardet, urllib3, Pillow, pbr, f
lake8, certifi, requests, mock
  Running setup.py install for Send2Trash ... done
  Running setup.py install for future ... done
  Running setup.py install for configparser ... done
Successfully installed Pillow-9.3.0 Send2Trash-1.3.0 certifi-2022.12.7 chardet-3.0.4 click-6.6 configparser-3.5.0 flake8-2.6.2 future-0.16.0 idna-2.7 mccabe-0.5.3
 mock-1.3.0 nose-1.3.7 pbr-5.11.0 pycodestyle-2.0.0 pyflakes-1.2.3 requests-2.20.0 six-1.9.0 tabulate-0.7.7 urllib3-1.24.3
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the 'C:\code\py\elodie_upstream\py310venv\Scripts\python.exe -m pip install --upgrade pip' command.

(py310venv) C:\code\py\elodie_upstream>python elodie/tests/run_tests.py
Traceback (most recent call last):
  File "C:\code\py\elodie_upstream\elodie\tests\run_tests.py", line 36, in <module>
    result = nose.run(argv=test_argv)
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\core.py", line 301, in run
    return TestProgram(*arg, **kw).success
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\core.py", line 118, in __init__
    unittest.TestProgram.__init__(
  File "C:\pythons\Python310\lib\unittest\main.py", line 100, in __init__
    self.parseArgs(argv)
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\core.py", line 179, in parseArgs
    self.createTests()
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\core.py", line 193, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames)
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\loader.py", line 481, in loadTestsFromNames
    return unittest.TestLoader.loadTestsFromNames(self, names, module)
  File "C:\pythons\Python310\lib\unittest\loader.py", line 220, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\pythons\Python310\lib\unittest\loader.py", line 220, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\loader.py", line 454, in loadTestsFromName
    return LazySuite(
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\suite.py", line 53, in __init__
    super(LazySuite, self).__init__()
  File "C:\pythons\Python310\lib\unittest\suite.py", line 22, in __init__
    self._tests = []
  File "C:\code\py\elodie_upstream\py310venv\lib\site-packages\nose\suite.py", line 106, in _set_tests
    if isinstance(tests, collections.Callable) and not is_suite:
AttributeError: module 'collections' has no attribute 'Callable'
@clach04
Copy link
Contributor Author

clach04 commented Nov 12, 2022

Looks like upstream tabulate already fixed python > 3.9 issue(s)

https://github.com/astanin/python-tabulate/blob/83fd4fb98926c8a6fdf45caa1b91ee8913b64dcb/tabulate/__init__.py#L4

@clach04
Copy link
Contributor Author

clach04 commented Nov 12, 2022

diff --git a/requirements.txt b/requirements.txt
index 33f5dbb..8484b21 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,5 +5,6 @@ future==0.16.0
 configparser==3.5.0
 tabulate==0.7.7
 Pillow==6.2.2; python_version == '2.7'
-Pillow==8.0; python_version >= '3.6'
+#Pillow==8.0; python_version >= '3.6'
+Pillow==9.3.0; python_version >= '3.6'
 six==1.9

@jmathai
Copy link
Owner

jmathai commented Nov 13, 2022

I'll fix this once I get the tests updated to work with the new MapQuest API (gh-421).

@jmathai
Copy link
Owner

jmathai commented Nov 21, 2022

Nose (the testing framework used for this project) does not support python 3.10. Fixing these errors and passing tests looks like it requires a larger effort of moving to pytest or similar.

@gilles6
Copy link

gilles6 commented Nov 21, 2022

What workaround can/should we use on macos ?

@jmathai
Copy link
Owner

jmathai commented Nov 21, 2022

You can download python 3.9 for OSX or use homebrew.

@clach04
Copy link
Contributor Author

clach04 commented Nov 22, 2022

Nose (the testing framework used for this project) does not support python 3.10. Fixing these errors and passing tests looks like it requires a larger effort of moving to pytest or similar.

yikes, just checked into this, options appear to be:

  1. try version in github (not pypi version) Distributed version of nose differ from GitHub repository and is not Python 3.10 compatible nose-devs/nose#1118 suggests this is worth trying, i.e. pip install with a git url
  2. move to nose2 https://github.com/nose-devs/nose2 .... which apparently/might requires changing tests, nose (v1) is apparently no longer maintained which is not clear from https://github.com/nose-devs/nose
  3. move to pytest -- which seems the most practical as a stable target.

It maybe that number 2 is less work but I don't have a good feeling about it (and no hard facts).

refs:

I'm still using unittest/unittest2 for my personal projects but the other runners have much nicer run options.

@gilles6
Copy link

gilles6 commented Nov 22, 2022

@jmathai Thanks
I'm getting the following error when using python 3.9:

$ python3.9 ~/elodie/elodie.py
Traceback (most recent call last):
  File "/Users/me/elodie/elodie.py", line 9, in <module>
    import click
ModuleNotFoundError: No module named 'click'

@jmathai
Copy link
Owner

jmathai commented Nov 22, 2022

@gilles6 Did you run pip install -r requirements.txt?

@gilles6
Copy link

gilles6 commented Nov 22, 2022

@jmathai Yes, I did

~/elodie master $ pip install -r requirements.txt
Ignoring Pillow: markers 'python_version == "2.7"' don't match your environment
Requirement already satisfied: click==6.6 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 1)) (6.6)
Requirement already satisfied: requests==2.20.0 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 2)) (2.20.0)
Requirement already satisfied: Send2Trash==1.3.0 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 3)) (1.3.0)
Requirement already satisfied: future==0.16.0 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 4)) (0.16.0)
Requirement already satisfied: configparser==3.5.0 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 5)) (3.5.0)
Requirement already satisfied: tabulate==0.7.7 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 6)) (0.7.7)
Requirement already satisfied: Pillow==9.3 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 8)) (9.3.0)
Requirement already satisfied: six==1.9 in /usr/local/lib/python3.10/site-packages (from -r requirements.txt (line 9)) (1.9.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/site-packages (from requests==2.20.0->-r requirements.txt (line 2)) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests==2.20.0->-r requirements.txt (line 2)) (2022.9.24)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests==2.20.0->-r requirements.txt (line 2)) (2.7)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.10/site-packages (from requests==2.20.0->-r requirements.txt (line 2)) (1.24.3)
$ cd ~/Pictures/test
$ python3.9 ~/elodie/elodie.py input output
Traceback (most recent call last):
  File "/Users/me/elodie/elodie.py", line 9, in <module>
    import click
ModuleNotFoundError: No module named 'click'

@jmathai
Copy link
Owner

jmathai commented Nov 22, 2022

Your pip install -r requirements.txt is installing the packages for python 3.10. You can see this in the path which is being referenced (Requirement already satisfied: click==6.6 in /usr/local/lib/python3.10/site-packages).

Try this instead. python3.9 -m pip install -r requirements.txt

@patsevanton
Copy link

Same issue on Python 3.10

Traceback (most recent call last):
  File "/home/user/IdeaProjects/elodie/./elodie.py", line 32, in <module>
    from elodie.result import Result
  File "/home/user/IdeaProjects/elodie/elodie/result.py", line 1, in <module>
    from tabulate import tabulate
  File "/home/user/IdeaProjects/elodie/venv/lib/python3.10/site-packages/tabulate.py", line 7, in <module>
    from collections import namedtuple, Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

@webysther
Copy link

webysther commented Feb 11, 2023

How to fix working with python 3.9 on ubuntu 22+:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.9
sudo apt install python3.9-distutils
python3.9 -m pip install -r requirements.txt
python3.9 ./elodie.py import --help

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

5 participants