PeepDB-dev / peepdb

CLI tool and python library to inspect databases fast.
https://docs.peepdb.dev/
GNU General Public License v3.0
290 stars 15 forks source link

ModuleNotFoundError: No module named 'mysql' #47

Closed khaldon closed 1 month ago

khaldon commented 1 month ago

I was setup the environment I got this error when i run the test

=================================== test session starts ===================================
platform linux -- Python 3.11.5, pytest-7.4.0, pluggy-1.0.0
rootdir: /home/mohamed/peepdb
plugins: anyio-4.2.0
collected 0 items / 4 errors                                                              

========================================= ERRORS ==========================================
________________________ ERROR collecting peepdb/tests/test_cli.py ________________________
ImportError while importing test module '/home/mohamed/peepdb/peepdb/tests/test_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
peepdb/tests/test_cli.py:3: in <module>
    from peepdb.cli import cli
peepdb/cli.py:2: in <module>
    from .core import peep_db
peepdb/core.py:4: in <module>
    from .db import MySQLDatabase, PostgreSQLDatabase, MariaDBDatabase, MongoDBDatabase
peepdb/db/__init__.py:1: in <module>
    from .mysql import MySQLDatabase
peepdb/db/mysql.py:1: in <module>
    import mysql.connector
E   ModuleNotFoundError: No module named 'mysql'
____________________ ERROR collecting peepdb/tests/test_connection.py _____________________
ImportError while importing test module '/home/mohamed/peepdb/peepdb/tests/test_connection.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
peepdb/tests/test_connection.py:1: in <module>
    import mysql.connector
E   ModuleNotFoundError: No module named 'mysql'
____________________ ERROR collecting peepdb/tests/test_data_types.py _____________________
ImportError while importing test module '/home/mohamed/peepdb/peepdb/tests/test_data_types.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
peepdb/tests/test_data_types.py:5: in <module>
    from peepdb.db import MySQLDatabase
peepdb/db/__init__.py:1: in <module>
    from .mysql import MySQLDatabase
peepdb/db/mysql.py:1: in <module>
    import mysql.connector
E   ModuleNotFoundError: No module named 'mysql'
______________________ ERROR collecting peepdb/tests/test_peepdb.py _______________________
ImportError while importing test module '/home/mohamed/peepdb/peepdb/tests/test_peepdb.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../anaconda3/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
peepdb/tests/test_peepdb.py:3: in <module>
    from peepdb.core import peep_db
peepdb/core.py:4: in <module>
    from .db import MySQLDatabase, PostgreSQLDatabase, MariaDBDatabase, MongoDBDatabase
peepdb/db/__init__.py:1: in <module>
    from .mysql import MySQLDatabase
peepdb/db/mysql.py:1: in <module>
    import mysql.connector
E   ModuleNotFoundError: No module named 'mysql'
================================= short test summary info =================================
ERROR peepdb/tests/test_cli.py
ERROR peepdb/tests/test_connection.py
ERROR peepdb/tests/test_data_types.py
ERROR peepdb/tests/test_peepdb.py
!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 4 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!
==================================== 4 errors in 0.15s ====================================

I installed the dependencies as mentioned in contribute file but I got also error when I am installing environment

Obtaining file:///home/mohamed/peepdb
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Collecting mysql-connector-python>=9.0.0 (from peepdb==0.1.3)
  Obtaining dependency information for mysql-connector-python>=9.0.0 from https://files.pythonhosted.org/packages/60/53/7468007a8f9d5b1f251b50039969a600e84114934d1369d6f7090e24369d/mysql_connector_python-9.0.0-cp311-cp311-manylinux_2_17_x86_64.whl.metadata
  Using cached mysql_connector_python-9.0.0-cp311-cp311-manylinux_2_17_x86_64.whl.metadata (2.0 kB)
Collecting psycopg2-binary>=2.9.9 (from peepdb==0.1.3)
  Obtaining dependency information for psycopg2-binary>=2.9.9 from https://files.pythonhosted.org/packages/ce/85/62825cabc6aad53104b7b6d12eb2ad74737d268630032d07b74d4444cb72/psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata
  Using cached psycopg2_binary-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.4 kB)
Collecting pymysql>=1.1.1 (from peepdb==0.1.3)
  Obtaining dependency information for pymysql>=1.1.1 from https://files.pythonhosted.org/packages/0c/94/e4181a1f6286f545507528c78016e00065ea913276888db2262507693ce5/PyMySQL-1.1.1-py3-none-any.whl.metadata
  Using cached PyMySQL-1.1.1-py3-none-any.whl.metadata (4.4 kB)
Collecting cryptography>=43.0.0 (from peepdb==0.1.3)
  Obtaining dependency information for cryptography>=43.0.0 from https://files.pythonhosted.org/packages/ac/7e/ebda4dd4ae098a0990753efbb4b50954f1d03003846b943ea85070782da7/cryptography-43.0.1-cp39-abi3-manylinux_2_28_x86_64.whl.metadata
  Using cached cryptography-43.0.1-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (5.4 kB)
Collecting tabulate>=0.8.9 (from peepdb==0.1.3)
  Obtaining dependency information for tabulate>=0.8.9 from https://files.pythonhosted.org/packages/40/44/4a5f08c96eb108af5cb50b41f76142f0afa346dfa99d5296fe7202a11854/tabulate-0.9.0-py3-none-any.whl.metadata
  Using cached tabulate-0.9.0-py3-none-any.whl.metadata (34 kB)
Collecting click>=8.0.0 (from peepdb==0.1.3)
  Obtaining dependency information for click>=8.0.0 from https://files.pythonhosted.org/packages/00/2e/d53fa4befbf2cfa713304affc7ca780ce4fc1fd8710527771b58311a3229/click-8.1.7-py3-none-any.whl.metadata
  Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting mariadb (from peepdb==0.1.3)
  Using cached mariadb-1.1.10.tar.gz (84 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [34 lines of output]
      /bin/sh: 1: mariadb_config: not found
      Traceback (most recent call last):
        File "/home/mohamed/peepdb/peepDB/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/mohamed/peepdb/peepDB/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/mohamed/peepdb/peepDB/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ce6j0cd2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-build-env-ce6j0cd2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-ce6j0cd2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 503, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/tmp/pip-build-env-ce6j0cd2/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup
          exec(code, locals())
        File "<string>", line 27, in <module>
        File "/tmp/pip-install-4d8oa4mv/mariadb_9b6c7681985c40bbb0a5a71bffe6c39b/mariadb_posix.py", line 62, in get_config
          cc_version = mariadb_config(config_prg, "cc_version")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/tmp/pip-install-4d8oa4mv/mariadb_9b6c7681985c40bbb0a5a71bffe6c39b/mariadb_posix.py", line 28, in mariadb_config
          raise EnvironmentError(
      OSError: mariadb_config not found.

      This error typically indicates that MariaDB Connector/C, a dependency which
      must be preinstalled, is not found.
      If MariaDB Connector/C is not installed, see installation instructions
      If MariaDB Connector/C is installed, either set the environment variable
      MARIADB_CONFIG or edit the configuration file 'site.cfg' to set the
       'mariadb_config' option to the file location of the mariadb_config utility.

      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

I don't know is that error related to the main error in the test or not ?

khaldon commented 1 month ago

I solved the issue