欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

CVAT抽离容器遇到的问题

程序员文章站 2024-03-12 14:01:08
...
  1. 安装postgreSQL失败
Collecting psycopg2-binary==2.7.4
  Using cached https://mirrors.aliyun.com/pypi/packages/77/09/4991fcd9a8f4bea1ee3948e1729fa17c184d25bd10809bacc143626361b9/psycopg2-binary-2.7.4.tar.gz (426 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/konkii/pyvirenv/cvat/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-c7_sgpod/psycopg2-binary/setup.py'"'"'; __file__='"'"'/tmp/pip-install-c7_sgpod/psycopg2-binary/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info
         cwd: /tmp/pip-install-c7_sgpod/psycopg2-binary/
    Complete output (23 lines):
    running egg_info
    creating /tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info
    writing /tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/dependency_links.txt
    writing top-level names to /tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-c7_sgpod/psycopg2-binary/pip-egg-info/psycopg2_binary.egg-info/SOURCES.txt'
    
    Error: pg_config executable not found.
    
    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:
    
        python setup.py build_ext --pg-config /path/to/pg_config build ...
    
    or with the pg_config option in 'setup.cfg'.
    
    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.
    
    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).
    
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

解决方案:这个模块是用来调用posrgreSQL的,按提示需要pg_config,可以尝试apt安装,若已安装,则可以使用locate定位到pg_config的路径,使用export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH命令加入PATH
2. 改用MySQL后的字段长度限制
2.1.

  Applying engine.0001_initial...Traceback (most recent call last):
  File "/home/konkii/pyvirenv/cvat/lib/python3.7/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/konkii/pyvirenv/cvat/lib/python3.7/site-packages/django/db/backends/mysql/base.py", line 71, in execute
    return self.cursor.execute(query, args)
  File "/home/konkii/pyvirenv/cvat/lib/python3.7/site-packages/MySQLdb/cursors.py", line 209, in execute
    res = self._query(query)
  File "/home/konkii/pyvirenv/cvat/lib/python3.7/site-packages/MySQLdb/cursors.py", line 315, in _query
    db.query(q)
  File "/home/konkii/pyvirenv/cvat/lib/python3.7/site-packages/MySQLdb/connections.py", line 239, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1071, 'Specified key was too long; max key length is 3072 bytes')

The above exception was the direct cause of the following exception:

解决方案:参考MySQL 经典案例分析:Specified key was too long,
在engine/models.py 中定义的ClientFile模型定义了unique_together属性,会在mysql中创建索引

class ClientFile(models.Model):
    task = models.ForeignKey(Task, on_delete=models.CASCADE)
    file = models.FileField(upload_to=upload_path_handler,
                            max_length=1024, storage=MyFileSystemStorage())
    class Meta:
        default_permissions = ()
        unique_together = ("task", "file")

显然task_id和file的总长度超过了3072字节,所以把file的max_length缩小就可以了。

2.2.

(cvat) [email protected]:~/program/vtag$ python manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
annotation.AnnotationDumper.display_name: (mysql.E001) MySQL does not allow unique CharFields to have a max_length > 255.
annotation.AnnotationLoader.display_name: (mysql.E001) MySQL does not allow unique CharFields to have a max_length > 255.

解决方案:cvat/apps/annotations/models.py 中的AnnotationHandler类的display_name(primaey_key)字段长度改为255