Azure / PyRIT

The Python Risk Identification Tool for generative AI (PyRIT) is an open access automation framework to empower security professionals and machine learning engineers to proactively find risks in their generative AI systems.
MIT License
1.89k stars 362 forks source link

bug: Azure SQL Tests Fail in MacOS M1 #263

Closed dlmgary closed 2 months ago

dlmgary commented 4 months ago

Describe the bug

Tests in PyRIT/tests/memory/test_azure_sql_memory.py fail to run in MacOS.

Steps/Code to Reproduce

Expected Results

Test passing

Actual Results

ERROR                 [ 18%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR               [ 18%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR       [ 18%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR            [ 18%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR     [ 19%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR     [ 19%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR                [ 19%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR               [ 19%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR [ 20%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR [ 20%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR [ 20%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError
ERROR [ 20%]
test setup failed
@pytest.fixture
    def memory_interface() -> Generator[AzureSQLMemory, None, None]:
>       yield from get_azure_sql_memory()

memory/test_azure_sql_memory.py:27: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mocks.py:117: in get_azure_sql_memory
    azure_sql_memory = AzureSQLMemory(
../pyrit/common/singleton.py:21: in __call__
    cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
../pyrit/memory/azure_sql_memory.py:38: in __init__
    self.engine = self._create_engine(has_echo=verbose)
../pyrit/memory/azure_sql_memory.py:55: in _create_engine
    engine = create_engine(self._connection_string, echo=has_echo)
<string>:2: in create_engine
    ???
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py:281: in warned
    return fn(*args, **kwargs)  # type: ignore[no-any-return]
/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/engine/create.py:599: in create_engine
    dbapi = dbapi_meth(**dbapi_args)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'sqlalchemy.dialects.mssql.pyodbc.MSDialect_pyodbc'>

    @classmethod
    def import_dbapi(cls) -> ModuleType:
>       return __import__("pyodbc")
E       ImportError: dlopen(/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so, 0x0002): Library not loaded: /usr/local/opt/unixodbc/lib/libodbc.2.dylib
E         Referenced from: <87BCBDCC-3D15-3E21-BD10-42E710460D5A> /Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/pyodbc.cpython-310-darwin.so
E         Reason: tried: '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/opt/unixodbc/lib/libodbc.2.dylib' (no such file), '/usr/local/lib/libodbc.2.dylib' (no such file), '/usr/lib/libodbc.2.dylib' (no such file, not in dyld cache)

/Users/gary/miniconda3/envs/pyrit/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py:60: ImportError

Screenshots

Versions

Python dependencies: pyrit: 0.2.2.dev0 Cython: None numpy: 1.26.4 openai: 1.25.1 pip: 24.0 scikit-learn: 1.4.2 scipy: 1.12.0 setuptools: 69.1.1 tensorflow: None torch: 2.1.2 transformers: 4.40.1

romanlutz commented 4 months ago

CC @elgertam @rdheekonda

elgertam commented 4 months ago

Hi @dlmgary, using SQL Server requires an ODBC-based driver to connect to SQL Server. The best supported library in Python is PyODBC, which allows Python to speak to an ODBC implementation. On Windows, ODBC is present out of the box, but on Linux & macOS, the end user must install an ODBC library like unixODBC (macOS or Linux) or iODBC (macOS only).

The errors listed indicate that PyODBC cannot find the shared library needed to initiate the ODBC connection, and thus PyODBC cannot be loaded, causing any references to it to fail.

During development on my Mac, I was able to use PyODBC with unixODBC. I did have to configure a couple of the INI configuration files on my machine to make everything work.

I wrote up a bit of documentation here and you can also check out the unixODBC docs and the PyODBC docs.

Let me know if you have any other issues or more specific questions. I can copy-paste some of my configs if you're still struggling to get this to work. Setting up PyODBC is non-trivial, but once you get it working, it more or less never stops.

CC @romanlutz @rdheekonda