ubuntu16.04安装python2.7+QT4的labelImg

1 安装依赖

sudo apt-get install pyqt4-dev-tools
sudo pip install lxml
git clone https://github.com/tzutalin/labelImg.git
cd labelImg

参考链接:https://blog.csdn.net/learning_tortosie/article/details/80947301#commentBox

2 编译

        我这里选择了python2版本的,此处需要编译一下。这个链接中:https://blog.csdn.net/learning_tortosie/article/details/80947301#commentBox。命令为

make all

我运行一直报错,如下:

        利用anaconda跟更换python环境也不行(大概率不是python环境的问题);参考链接:https://blog.csdn.net/comway_Li/article/details/85046102,将上述命令改为:make py2qt4,发现编译通过,如下图所示:

3 运行程序

        输入命令如下,注意labelImg.py中的“I”为大写:

python labelImg.py 

(其他形式打开labelImg)

python labelImg.py [IMAGE_PATH] [PRE-DEFINED CLASS FILE]

        报错:

RuntimeError: the PyQt4.QtCore and PyQt5.QtCore modules both wrap the QObject class

,这里是qt版本问题,环境中装了qt4、qt5两个版本冲突了,其中qt4与python2、qt5与python3匹配,这里是python2环境,需要将qt5卸载:

sudo apt-get remove python-pyqt5

        之后运行:

python labelImg.py

报错:

$ python labelImg.py              
Traceback (most recent call last):
  File "labelImg.py", line 43, in <module>
    from libs.labelFile import LabelFile, LabelFileError, LabelFileFormat
  File "/home/meng/2020A1/2021train/labelimg/labelImg/libs/labelFile.py", line 13, in <module>
    from libs.create_ml_io import CreateMLWriter
  File "/home/meng/2020A1/2021train/labelimg/labelImg/libs/create_ml_io.py", line 4, in <module>
    from pathlib import Path
ImportError: No module named pathlib

        参考stack overflow的一个issue:https://stackoverflow.com/questions/62910916/importerror-no-module-named-pathlib/62911276。输入:

sudo pip install --upgrade --no-deps --force-reinstall pathlib

        再执行:

python labelImg.py

        结果如下,即成功打开/安装labelImg:

$ sudo pip install --upgrade --no-deps --force-reinstall pathlib
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: The directory '/home/meng/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pathlib
  Downloading pathlib-1.0.1.tar.gz (49 kB)
     |████████████████████████████████| 49 kB 150 kB/s 
Building wheels for collected packages: pathlib
  Building wheel for pathlib (setup.py) ... done
  Created wheel for pathlib: filename=pathlib-1.0.1-py2-none-any.whl size=16366 sha256=b27cb0763fde2eddf3be8d8cfb5765bd227cb8d0226136d04174f82da943a452
  Stored in directory: /tmp/pip-ephem-wheel-cache-qvq5u5/wheels/46/37/4f/332bcea757140ff34e14dec7be65931f544c7ac94eb671ae9f
Successfully built pathlib
Installing collected packages: pathlib
Successfully installed pathlib-1.0.1

        软件界面如下:

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值