본문 바로가기

Python

[Python] pip install mariadb - MariaDB Connector/Python requires MariaDB Connector/C >= 3.3.1, found version 3.1.20 (feat. ubuntu / Docker)

반응형

다른에러에서 oserror 해결하고 오니까 또 에러가 난다.

 

Error

 pip install mariadb
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'pypi.ngc.nvidia.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
Collecting mariadb
  Downloading mariadb-1.1.6.tar.gz (83 kB)
     |████████████████████████████████| 83 kB 8.8 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 2:
   command: /test/.venv/bin/python3 /tmp/tmp8p9nk1v9 get_requires_for_build_wheel /tmp/tmpu5y08oot
       cwd: /tmp/pip-install-9r2z5fs5/mariadb
  Complete output (1 lines):
  MariaDB Connector/Python requires MariaDB Connector/C >= 3.3.1, found version 3.1.20
  ----------------------------------------
ERROR: Command errored out with exit status 2: /test/.venv/bin/python3 /tmp/tmp8p9nk1v9 get_requires_for_build_wheel /tmp/tmpu5y08oot Check the logs for full command output.

버전이 너무 낮다는건가..? 윗버전을 다운로드 받아보았다.

wget https://dlm.mariadb.com/2678574/Connectors/c/connector-c-3.3.3/mariadb-connector-c-3.3.3-debian-bullseye-amd64.tar.gz -O - | tar -zxf - --strip-components=1 -C /usr

다운로드 경로

https://mariadb.com/downloads/connectors/

 

Download MariaDB Connectors for data access & analysis | MariaDB

Download MariaDB Connector/Python, MariaDB Connector/C, MariaDB Connector/J, MariaDB Connector/Node.js, MariaDB Connector/R2DBC, MariaDB Connector/ODBC and more

mariadb.com

 

또 에러가 난다.

python app/main.py
Traceback (most recent call last):
  File "app/main.py", line 7, in <module>
    from routers import auth, user
  File "/test/app/routers/auth.py", line 4, in <module>
    from database import get_db
  File "/test/app/database.py", line 11, in <module>
    engine = create_engine(SQLALCHEMY_DATABASE_URL, echo=True)
  File "<string>", line 2, in create_engine
  File "/test/.venv/lib/python3.8/site-packages/sqlalchemy/util/deprecations.py", line 277, in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
  File "/test/.venv/lib/python3.8/site-packages/sqlalchemy/engine/create.py", line 605, in create_engine
    dbapi = dbapi_meth(**dbapi_args)
  File "/test/.venv/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mariadbconnector.py", line 117, in import_dbapi
    return __import__("mariadb")
  File "/test/.venv/lib/python3.8/site-packages/mariadb/__init__.py", line 7, in <module>
    from ._mariadb import (
ImportError: MariaDB Connector/Python was build with MariaDB Connector/C 3.3.3, while the loaded MariaDB Connector/C library has version 3.1.20.

 

이번엔 MariaDB Connector/C  의 버전 안맞다는것 같다...

 

진퇴양난이다...

 

일반 mariadb-connector를 복구해놓고

wget https://dlm.mariadb.com/2862525/Connectors/c/connector-c-3.1.20/mariadb-connector-c-3.1.20-ubuntu-focal-amd64.tar.gz -O - | tar -zxf - --strip-components=1 -C /usr

mariadb-connector 3.1.2 버전과 호환 되는 버전으로 install 해봤다.

pip install mariadb==1.0.3

Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl/urllib3/connectionpool.py:999: InsecureRequestWarning: Unverified HTTPS request is being made to host 'pypi.ngc.nvidia.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
Collecting mariadb==1.0.3
  Downloading mariadb-1.0.3.tar.gz (66 kB)
     |████████████████████████████████| 66 kB 7.2 MB/s
Building wheels for collected packages: mariadb
  Building wheel for mariadb (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /test/.venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ryb2lqy9/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ryb2lqy9/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-mzgtogmp
       cwd: /tmp/pip-install-ryb2lqy9/mariadb/
  Complete output (6 lines):
  usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: setup.py --help [cmd1 cmd2 ...]
     or: setup.py --help-commands
     or: setup.py cmd --help

  error: invalid command 'bdist_wheel'
  ----------------------------------------
  ERROR: Failed building wheel for mariadb
  Running setup.py clean for mariadb
Failed to build mariadb
Installing collected packages: mariadb
    Running setup.py install for mariadb ... done
Successfully installed mariadb-1.0.3

error 났으면서 successfully는 왜 뜨는걸까 ㅂㄷㅂㄷ

일단 저 에러를 봄녀 bdist_whell이라는 명령어가 없는데 사용해서 그렇다고 한다.

whell이 뭔가 다운받을 때 사용하는것 같은데

아래 명령어를 사용하면 사용하지 않고 다운 받을 수 있다고 한다.

해결

pip install mariadb==1.0.3 --no-binary mariadb

 

잘된다.

 

다른 에러

[Python] pip install mariadb - Python: OSError: mariadb_config not found. (feat. ubuntu)

 

[Python] pip install mariadb - Python: OSError: mariadb_config not found. (feat. ubuntu)

해결 apt install libmariadb-dev 원인은 필요한게 없어서 그런건데 오류를 보면 보다시피 mariadb_config가 없다고 한다. 그래서 관련 라이브러리를 install 해준다. Build prerequisites The following build prerequisites a

24hours-beginner.tistory.com

https://24hours-beginner.tistory.com/450

 

[python] pip install mariadb - E: Package 'python-dev' has no installation candidate (feat. ubuntu)

Error Downloading mariadb-1.0.3.tar.gz (66 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.6/66.6 KB 4.8 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Skipping wheel

24hours-beginner.tistory.com

 

반응형