HumanSignal / labelImg

LabelImg is now part of the Label Studio community. The popular image annotation tool created by Tzutalin is no longer actively being developed, but you can check out Label Studio, the open source data labeling tool for images, text, hypertext, audio, video and time-series data.
https://youtu.be/p0nR2YsCY_U
MIT License
22.19k stars 6.23k forks source link

(Found workaround) Can't install in Virtual environment on M1 #935

Open trueToastedCode opened 1 year ago

trueToastedCode commented 1 year ago

My best solution: Using Parallels Desktop to run the Windows version :(

python3 -m pipenv run pip install pyqt5==5.15.2 lxml
Creating a virtualenv for this project...
Pipfile: /Users/lennard/Any/Pipfile
Using /usr/bin/python3 (3.8.9) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.8.9.final.0-64 in 163ms
  creator CPython3macOsFramework(dest=/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/lennard/Library/Application Support/virtualenv)
    added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B
Creating a Pipfile for this project...
Collecting pyqt5==5.15.2
  Using cached PyQt5-5.15.2.tar.gz (3.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 156, in prepare_metadata_for_build_wheel
          hook = backend.prepare_metadata_for_build_wheel
      AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

      During handling of the above exception, another exception occurred:

      Traceback (most recent call last):
        File "/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 160, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/sipbuild/api.py", line 46, in build_wheel
          project = AbstractProject.bootstrap('wheel',
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/sipbuild/abstract_project.py", line 87, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 584, in setup
          self.apply_user_defaults(tool)
        File "project.py", line 63, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/pyqtbuild/project.py", line 70, in apply_user_defaults
          super().apply_user_defaults(tool)
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 236, in apply_user_defaults
          self.builder.apply_user_defaults(tool)
        File "/private/var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/pip-build-env-62j7j5v5/overlay/lib/python3.8/site-packages/pyqtbuild/builder.py", line 67, in apply_user_defaults
          raise PyProjectOptionException('qmake',
      sipbuild.pyproject.PyProjectOptionException
      [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.
python3 -m pipenv run pip install pyqt6 lxml        
Creating a virtualenv for this project...
Pipfile: /Users/lennard/Any/Pipfile
Using /usr/bin/python3 (3.8.9) to create virtualenv...
⠹ Creating virtual environment...created virtual environment CPython3.8.9.final.0-64 in 158ms
  creator CPython3macOsFramework(dest=/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/Users/lennard/Library/Application Support/virtualenv)
    added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B
Creating a Pipfile for this project...
Collecting pyqt6
  Using cached PyQt6-6.3.1-cp37-abi3-macosx_10_14_universal2.whl (11.7 MB)
Collecting lxml
  Using cached lxml-4.9.1.tar.gz (3.4 MB)
  Preparing metadata (setup.py) ... done
Collecting PyQt6-sip<14,>=13.4
  Using cached PyQt6_sip-13.4.0.tar.gz (111 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting PyQt6-Qt6>=6.3.0
  Using cached PyQt6_Qt6-6.3.1-py3-none-macosx_11_0_arm64.whl (32.5 MB)
Building wheels for collected packages: lxml, PyQt6-sip
  Building wheel for lxml (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [93 lines of output]
      Building lxml version 4.9.1.
      Building without Cython.
      Building against libxml2 2.9.4 and libxslt 1.1.29
      Building against libxml2/libxslt in the following directory: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-arm64-cpython-38
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/_elementpath.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/sax.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/pyclasslookup.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/__init__.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/builder.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/doctestcompare.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/usedoctest.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/cssselect.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/ElementInclude.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/__init__.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/soupparser.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/defs.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/_setmixin.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/clean.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/_diffcommand.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/html5parser.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/__init__.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/formfill.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/builder.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/ElementSoup.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/_html5builder.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/usedoctest.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      copying src/lxml/html/diff.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/html
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron
      copying src/lxml/isoschematron/__init__.py -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron
      copying src/lxml/etree.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/etree_api.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/lxml.etree.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/lxml.etree_api.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml
      copying src/lxml/includes/xmlerror.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/c14n.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/xmlschema.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/__init__.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/schematron.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/tree.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/uri.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/etreepublic.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/xpath.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/htmlparser.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/xslt.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/config.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/xmlparser.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/xinclude.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/dtdvalid.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/relaxng.pxd -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/lxml-version.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      copying src/lxml/includes/etree_defs.h -> build/lib.macosx-10.14-arm64-cpython-38/lxml/includes
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/rng
      copying src/lxml/isoschematron/resources/rng/iso-schematron.rng -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/rng
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl
      copying src/lxml/isoschematron/resources/xsl/XSD2Schtrn.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl
      copying src/lxml/isoschematron/resources/xsl/RNG2Schtrn.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl
      creating build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_abstract_expand.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_dsdl_include.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_skeleton_for_xslt1.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_svrl_for_xslt1.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/iso_schematron_message.xsl -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      copying src/lxml/isoschematron/resources/xsl/iso-schematron-xslt1/readme.txt -> build/lib.macosx-10.14-arm64-cpython-38/lxml/isoschematron/resources/xsl/iso-schematron-xslt1
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      building 'lxml.etree' extension
      creating build/temp.macosx-10.14-arm64-cpython-38
      creating build/temp.macosx-10.14-arm64-cpython-38/src
      creating build/temp.macosx-10.14-arm64-cpython-38/src/lxml
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DCYTHON_CLINE_IN_TRACEBACK=0 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Isrc -Isrc/lxml/includes -I/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -c src/lxml/etree.c -o build/temp.macosx-10.14-arm64-cpython-38/src/lxml/etree.o -w -flat_namespace
      src/lxml/etree.c:96:10: fatal error: 'Python.h' file not found
      #include "Python.h"
               ^~~~~~~~~~
      1 error generated.
      Compile failed: command '/usr/bin/clang' failed with exit code 1
      creating var
      creating var/folders
      creating var/folders/2x
      creating var/folders/2x/mntqls250t11_wmddl33ddj80000gn
      creating var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T
      cc -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/usr/include/libxml2 -c /var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/xmlXPathInitc95qjak2.c -o var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/xmlXPathInitc95qjak2.o
      cc var/folders/2x/mntqls250t11_wmddl33ddj80000gn/T/xmlXPathInitc95qjak2.o -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib -lxml2 -o a.out
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for lxml
  Running setup.py clean for lxml
  Building wheel for PyQt6-sip (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for PyQt6-sip (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'PyQt6.sip' extension
      creating build
      creating build/temp.macosx-10.14-arm64-cpython-38
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -I/Users/lennard/.local/share/virtualenvs/Any-HmM4yo8B/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -c sip_array.c -o build/temp.macosx-10.14-arm64-cpython-38/sip_array.o
      sip_array.c:21:10: fatal error: 'Python.h' file not found
      #include <Python.h>
               ^~~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for PyQt6-sip
Failed to build lxml PyQt6-sip
ERROR: Could not build wheels for PyQt6-sip, which is required to install pyproject.toml-based projects
trueToastedCode commented 1 year ago

Found a workaround:

  1. Find Terminal.app in Programs folder
  2. Duplicate and name it 'Rosetta Terminal'
  3. Open it with cmd+I and activate Rosetta
  4. Run 'Rosetta Terminal'
  5. Create virtual environment for labeling: mkdir ~/labelImg && cd ~/labelImg && python3 -m venv venv && source venv/bin/activate
  6. Now run installation pip install --upgrade pip && pip install pyqt5 lxml
  7. Start labelImg labelImg Bildschirmfoto 2022-09-04 um 13 10 41
developer239 commented 1 year ago

It was 11:30PM when I decided to install labelImg on my M1 system. The usual installation didn't work so I started searching for solutions and as a result installed many random Python libraries that were supposed to solve the problem.

It didn't work.

Then I decided to setup virtual environments. I even read @trueToastedCode 's workaround and created new Rosetta Terminal on my machine.

But it didn't work.

I am going to take a shower.

Then I will go to bed.

When I wake up I will probably buy a new computer because this mac will never recover from the amount commands and libraries that I force fed it with the terminal just so that I could label images at midnight.

image

Absolutely crazy 😂

image

edit:

Meanwhile Label Studio:

docker pull heartexlabs/label-studio:latest
docker run -it -p 8080:8080 -v `pwd`/mydata:/label-studio/data heartexlabs/label-studio:latest

Is there a difference? I will find out tomorrow.

playground commented 1 year ago

@developer239 did you get labelImg working on your M1?

I created a docker image but getting this error

root@1b6b364105be:/# labelImg
qt.qpa.xcb: could not connect to display /private/tmp/com.apple.launchd.DIUKRoRocN/org.xquartz:0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.

root@1b6b364105be:/# echo $DISPLAY
/private/tmp/com.apple.launchd.DIUKRoRocN/org.xquartz:0