当前位置: 首页>数据库>正文

连接mysql连了一上午

2024.3月17日配置了一上午,为啥报错?

GitHub+小G+独立分析

'主要是我的cryptography的版本太高,和openssl不匹配,所以就引起了incompatible(不兼容)'
最后看到了GitHub上面别人的问题:
Hey, I have trouble importing the wandb module on my M1 Chip.
I did the installation with the command:
pip install wandb.
But I get the following error, when trying to import wandb in PyCharm:
ImportError: dlopen(/Users/test/PycharmProjects/test_project/venv/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so, 0x0002): tried: '/Users/test/PycharmProjects/test_project/venv/lib/python3.9/site-packages/psutil/_psutil_osx.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_psutil_osx.cpython-39-darwin.so' (no such file), '/usr/lib/_psutil_osx.cpython-39-darwin.so' (no such file)
Any ideas how to handle this?

回答说:
Looks like there is an issue with psutil installing the incorrect binary, could you try the following
pip uninstall psutil
pip install --no-cache psutil
Thanks,
Ramit

我的:
ImportError: dlopen(/Users/benjamin/PycharmProjects/pythonProject7/venv/lib/python3.10/site-packages/_cffi_backend.cpython-310-darwin.so, 0x0002): tried: '/Users/benjamin/PycharmProjects/pythonProject7/venv/lib/python3.10/site-packages/_cffi_backend.cpython-310-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64')),

'通过一对比我去,发现问题所在,我直接uninstall cffi.  
然后又无缓存的下载了一下: pip install --no-cache cffi -i https://pypi.tuna.tsinghua.edu.cn/simple/'

然后就发现incompatible的问题,引发小G的答案:然后降低cryptography版本后就可以正常跑了
降低版本:
 pip install cryptography==41.0.5 -i https://pypi.tuna.tsinghua.edu.cn/simple/

setting.py文件中进行配置

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'your_database_name',
        'USER': 'your_mysql_username',
        'PASSWORD': 'your_mysql_password',
        'HOST': 'localhost',  # 或者是数据库服务器的IP地址
        'PORT': '3306',       # MySQL默认端口
    }
}

'ENGINE' 指定了使用的数据库后端,这里是 MySQL。
'NAME' 是您的数据库名称。
'USER' 和 'PASSWORD' 是连接数据库所需的用户名和密码。
'HOST' 是数据库服务器的地址,通常是 'localhost',也可以是 IP 地址。
'PORT' 是数据库服务器的端口,默认为 MySQL 的 3306。

运行迁移

python manage.py makemigrations
python manage.py migrate

https://www.xamrdz.com/database/6e91850443.html

相关文章: