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

Unable to install DisplayCal on Ubuntu 22.04 (Python 3.10.6) -> ImportError: cannot import name 'Mapping' from 'collections' #200

Closed
swiss-knight opened this issue Nov 1, 2022 · 10 comments

Comments

@swiss-knight
Copy link

Hello,

first of all, thanks for porting DisplayCal to Python3!

I'm currently experiencing some issue when trying to install DisplayCal using pip (22.3) on Ubuntu 22.04.1 :

$ pip3 install -U DisplayCal

Collecting DisplayCal
  Using cached DisplayCAL-3.9.8.tar.gz (10.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Collecting wxPython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-n5mg1oju/wxpython_4a3d4271ba5543cabc89737fcd9e416e/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-n5mg1oju/wxpython_4a3d4271ba5543cabc89737fcd9e416e/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/usr/local/lib/python3.10/dist-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/usr/local/lib/python3.10/dist-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
$ uname -mor
5.15.0-52-generic x86_64 GNU/Linux
python3 --version
Python 3.10.6
$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

I also encountered the same kind of issue by following the step-by-step installation procedure described in the README when trying to install it from source in a venv :

(displaycal_venv) username@workstation:/opt/displaycal-py3 (develop)$ pip install -r requirements.txt 
Defaulting to user installation because normal site-packages is not writeable
Collecting attrdict3
  Downloading attrdict3-2.0.2-py2.py3-none-any.whl (10 kB)
Collecting build
  Downloading build-0.9.0-py3-none-any.whl (17 kB)
Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 3)) (2022.6.15)
Requirement already satisfied: dbus-python in /usr/lib/python3/dist-packages (from -r requirements.txt (line 4)) (1.2.18)
Requirement already satisfied: distro in /usr/lib/python3/dist-packages (from -r requirements.txt (line 5)) (1.7.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 6)) (1.23.4)
Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 7)) (9.1.0)
Collecting PyChromecast
  Downloading PyChromecast-12.1.4-py2.py3-none-any.whl (62 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.1/62.1 kB 1.0 MB/s eta 0:00:00
Requirement already satisfied: Send2Trash in /usr/local/lib/python3.10/dist-packages (from -r requirements.txt (line 9)) (1.8.0)
Collecting wxPython>=4.1.1
  Downloading wxPython-4.2.0.tar.gz (71.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 71.0/71.0 MB 7.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-229w13cr/wxpython_dbf5d4fb09034658b34c54dfd2f41051/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-229w13cr/wxpython_dbf5d4fb09034658b34c54dfd2f41051/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/usr/local/lib/python3.10/dist-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/usr/local/lib/python3.10/dist-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Any hints on how to solve this issue are welcome.

I found this, which maybe can help: https://stackoverflow.com/a/69727802/6630397 but I'm not sure.

@p5k369
Copy link
Collaborator

p5k369 commented Nov 2, 2022

Hey @swiss-knight there is an issue that looks similar to yours can you please take a look at #174, especially at the comment #174 (comment).
Can you check if anything mentioned in that comment solves your problem?

@swiss-knight
Copy link
Author

swiss-knight commented Nov 9, 2022

Hello,

hmm, the same issue seems to pop when trying to install wxPython from PyPi :

$ pip3 install wxPython

Collecting wxPython
  Using cached wxPython-4.2.0.tar.gz (71.0 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-tc9ue5x7/wxpython_3af13eebb42c44119b2fc424407cbd51/setup.py", line 27, in <module>
          from buildtools.config import Config, msg, opj, runcmd, canGetSOName, getSOName
        File "/tmp/pip-install-tc9ue5x7/wxpython_3af13eebb42c44119b2fc424407cbd51/buildtools/config.py", line 30, in <module>
          from attrdict import AttrDict
        File "/usr/local/lib/python3.10/dist-packages/attrdict/__init__.py", line 5, in <module>
          from attrdict.mapping import AttrMap
        File "/usr/local/lib/python3.10/dist-packages/attrdict/mapping.py", line 4, in <module>
          from collections import Mapping
      ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I then wanted to force the install of the version wxPython==4.1.1:

$ pip3 install wxPython==4.1.1

Collecting wxPython==4.1.1
  Downloading wxPython-4.1.1.tar.gz (66.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.0/66.0 MB 1.1 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: pillow in /usr/local/lib/python3.10/dist-packages (from wxPython==4.1.1) (9.1.0)
Requirement already satisfied: six in /usr/local/lib/python3.10/dist-packages (from wxPython==4.1.1) (1.16.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from wxPython==4.1.1) (1.23.4)
Building wheels for collected packages: wxPython
  Building wheel for wxPython (setup.py) .../  # <---- the build actually takes some long minutes !
  

(you can use pip3 --verbose install wxPython==4.1.1 to see the progress of the compilation...)

As it's really very long to compile all the stuff, and as it seems to rely on gtk3: wxWidgets build options: ['--wxpython', '--unicode', '--gtk3'], I stopped the process and give an other idea that I had a chance:

$ apt install python3-wxgtk4.0

$ pip3 install -U DisplayCal
Collecting DisplayCal
  Using cached DisplayCAL-3.9.8.tar.gz (10.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: distro in /usr/lib/python3/dist-packages (from DisplayCal) (1.7.0)
Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from DisplayCal) (1.23.4)
Requirement already satisfied: certifi in /usr/local/lib/python3.10/dist-packages (from DisplayCal) (2022.6.15)
Requirement already satisfied: dbus-python in /usr/lib/python3/dist-packages (from DisplayCal) (1.2.18)
Requirement already satisfied: wxPython in /usr/lib/python3/dist-packages (from DisplayCal) (4.0.7)
Requirement already satisfied: Send2Trash in /usr/local/lib/python3.10/dist-packages (from DisplayCal) (1.8.0)
Requirement already satisfied: Pillow in /usr/local/lib/python3.10/dist-packages (from DisplayCal) (9.1.0)
Collecting build
  Using cached build-0.9.0-py3-none-any.whl (17 kB)
Collecting zeroconf
  Using cached zeroconf-0.39.4-py3-none-any.whl (106 kB)
Collecting PyChromecast
  Using cached PyChromecast-12.1.4-py2.py3-none-any.whl (62 kB)
Collecting pep517>=0.9.1
  Downloading pep517-0.13.0-py3-none-any.whl (18 kB)
Requirement already satisfied: tomli>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from build->DisplayCal) (2.0.1)
Requirement already satisfied: packaging>=19.0 in /usr/local/lib/python3.10/dist-packages (from build->DisplayCal) (21.3)
Collecting protobuf<4,>=3.19.1
  Downloading protobuf-3.20.3-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (1.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.1/1.1 MB 874.7 kB/s eta 0:00:00
Collecting casttube>=0.2.0
  Downloading casttube-0.2.1-py3-none-any.whl (6.5 kB)
Collecting ifaddr>=0.1.7
  Downloading ifaddr-0.2.0-py3-none-any.whl (12 kB)
Collecting async-timeout>=4.0.1
  Downloading async_timeout-4.0.2-py3-none-any.whl (5.8 kB)
Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from casttube>=0.2.0->PyChromecast->DisplayCal) (2.28.1)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from packaging>=19.0->build->DisplayCal) (3.0.9)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->casttube>=0.2.0->PyChromecast->DisplayCal) (1.26.12)
Requirement already satisfied: charset-normalizer<3,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->casttube>=0.2.0->PyChromecast->DisplayCal) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->casttube>=0.2.0->PyChromecast->DisplayCal) (3.3)
Building wheels for collected packages: DisplayCal
  Building wheel for DisplayCal (pyproject.toml) ... done
  Created wheel for DisplayCal: filename=DisplayCAL-3.9.8-cp310-cp310-linux_x86_64.whl size=8984704 sha256=4f8e73c2d215f75a7c3032067d6a41f46936d6d9ce5e0ab022f4880117a20181
  Stored in directory: /root/.cache/pip/wheels/9a/b0/22/2817d6280352bf7dc662e9b5df0a384a4ad37c0ce28c3065ca
Successfully built DisplayCal
Installing collected packages: ifaddr, protobuf, pep517, async-timeout, zeroconf, casttube, build, PyChromecast, DisplayCal
  Attempting uninstall: protobuf
    Found existing installation: protobuf 3.12.4
    Uninstalling protobuf-3.12.4:
      Successfully uninstalled protobuf-3.12.4
Successfully installed DisplayCal-3.9.8 PyChromecast-12.1.4 async-timeout-4.0.2 build-0.9.0 casttube-0.2.1 ifaddr-0.2.0 pep517-0.13.0 protobuf-3.20.3 zeroconf-0.39.4

=>

image

I may end up on some issues in the future because wxPython version is 4.0.7 when installed with apt on Ubuntu 22.04.1 :

$ apt-cache policy python3-wxgtk4.0 
python3-wxgtk4.0:
  Installed: 4.0.7+dfsg-13build1
  Candidate: 4.0.7+dfsg-13build1
  Version table:
 *** 4.0.7+dfsg-13build1 500
        500 http://ch.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status
        

But I will give it a try using an Xrite probe.

@swiss-knight
Copy link
Author

Well, it didn't take long to show some errors actually: e.g. when trying to open the "curve viewer":

Screenshot from 2022-11-09 20-58-28

@p5k369
Copy link
Collaborator

p5k369 commented Nov 9, 2022

Yes that will not work.
Install attrdict3 via pip and then reinstall wxpython with --no-cache-dir flag set.
Or just use 4.1.1. Depending on your machine, compiling might take some time, true.
Or you try official wheels from wxpython, they provide them for some distros and specific python versions, even we use them for some of our test pipelines: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/

@swiss-knight
Copy link
Author

Okay, thank you!

So, I first removed the wxPython package which was installed with apt:

$ apt remove --purge python3-wxgtk4.0

Then I removed DisplayCall with pip:

$ pip uninstall DisplayCal

After what I installed wxPython==4.1.1 with pip:

$ pip install --verbose --no-cache-dir wxPython==4.1.1

It took some times but everything went fine.

And I finally reinstalled DisplayCal with pip:

$ pip install --verbose --no-cache-dir DisplayCal

It successfully installed DisplayCal 3.9.8 but when launching some elements, I face the same issue than before ; 'dict_values' object is not subscriptable.

  • e.g. with the curve viewer:

Screenshot from 2022-11-10 10-19-37

  • or the ICC profile info:

Screenshot from 2022-11-10 10-25-25

Please notice that the warning about the deprecated version of wxPython at the bottom of those windows (compared to the previous screenshot I posted) has disappeared.

How could I make it work properly?

I also tried with pip install --upgrade wxPython which installed the latest wxPython 4.2.0 but the same problems occurred.

@swiss-knight
Copy link
Author

For maybe a more verbose version of the error, here's the log when I launch the curve-viewer with the command line:

$ displaycal-curve-viewer 
XDG: [Errno 2] No translation file found for domain: 'xdg-user-dirs'
Acquired lock file: <DisplayCAL.main.AppLock object at 0x7f6b0d693700>
displaycal-curve-viewer 3.9.8 2022-09-15T09:52:04Z
ubuntu 22.04 jammy x86_64
Python 3.10.6 (main, Nov  2 2022, 18:53:38) [GCC 11.3.0]
Faulthandler 
wxPython 4.1.1 gtk3 (phoenix) wxWidgets 3.1.5
Encoding: utf-8
File system encoding: utf-8
Loading /home/<username>/.config/DisplayCAL/DisplayCAL.ini
Existing client using port 35783
Existing client using port 32215
Existing client using port 40341
Existing client using port 41825
Existing client using port 14311
Existing client using port 45677
Existing client using port 31941
Existing client using port 35391
listening
writing to lock file: port: 44821
Gdk-Message: 10:29:44.741: Unable to load sizing from the cursor theme
Setting up scripting host at 127.0.0.1:45821
Enumerating display devices and communication ports...
/usr/bin
ArgyllCMS 2.2.0
Argyll has virtual display support
...ok.
NoneType: None
┌──────────────────────────────────────────────────────────────────────────────┐
│ Traceback (most recent call last):                                           │
│   File "/usr/local/lib/python3.10/dist-packages/wx/core.py", line 2326, in   │
│ Notify                                                                       │
│     self.notify()                                                            │
│   File "/usr/local/lib/python3.10/dist-packages/wx/core.py", line 3532, in   │
│ Notify                                                                       │
│     self.result = self.callable(*self.args, **self.kwargs)                   │
│   File "/usr/local/lib/python3.10/dist-packages/DisplayCAL/wxLUTViewer.py",  │
│ line 2516, in _main                                                          │
│     app.TopWindow.load_lut(get_display_profile(display_no))                  │
│   File "/usr/local/lib/python3.10/dist-packages/DisplayCAL/wxLUTViewer.py",  │
│ line 1276, in load_lut                                                       │
│     self.LoadProfile(profile)                                                │
│   File "/usr/local/lib/python3.10/dist-packages/DisplayCAL/wxLUTViewer.py",  │
│ line 1646, in LoadProfile                                                    │
│     if profile.getDescription():                                             │
│   File "/usr/local/lib/python3.10/dist-packages/DisplayCAL/ICCProfile.py",   │
│ line 7271, in getDescription                                                 │
│     return str(self.tags.get("desc", ""))                                    │
│   File "/usr/local/lib/python3.10/dist-packages/DisplayCAL/ICCProfile.py",   │
│ line 4796, in __str__                                                        │
│     return list(self.values())[0].values()[0]                                │
│ TypeError: 'dict_values' object is not subscriptable                         │
└──────────────────────────────────────────────────────────────────────────────┘

@p5k369
Copy link
Collaborator

p5k369 commented Nov 10, 2022

Oh, right. This should be a list of a list. Actually this is already fixed in the development branch but wasn't released yet.
If you don't mind you can clone the dev-branch via git, fix it quick and dirty by yourself or wait until the next release hits pypi.
@eoyilmaz would you mind merging the dev branch with the master and release the pip package?

@eoyilmaz
Copy link
Owner

Hey @p5k369 yeah sure I'll do it tonight 👍

@eoyilmaz
Copy link
Owner

Closing this one as it is already fixed.

@eoyilmaz
Copy link
Owner

Done: https://github.com/eoyilmaz/displaycal-py3/releases/tag/3.9.9

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

3 participants