大佬教程收集整理的这篇文章主要介绍了加载MySQLdb模块和“ pip install MySQLdb”时出错,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
显然,安装pip install MysqL-
python
是必经之路。问题出在MysqL_config的位置。环顾四周,这可能会因您的操作系统而有所帮助:安装MysqLdbpython接口时找不到MysqL_config
我遇到了这个问题,并通过将符号链接添加到来解决MysqL_config。
我已经用自制软件安装了MysqL,并在输出中看到了这一点。
Error: The `brew link` step dID not complete successfully
根据您的使用方式,MysqL它会在不同的地方。以我为例,/usr/local/Cellar/MysqL 一旦您知道它在哪里,就应该可以建立一个指向python寻找位置的符号链接。 /usr/local/MysqL
这对我有用。
ln -s /usr/local/Cellar/MysqL/<< VERSION >>/bin/MysqL_config /usr/local/MysqL/bin/MysqL_config
如果安装脚本失败Command "python setup.py egg_info" Failed with error code 1 in
{...}
,请使用以下命令安装libMysqLclIEnt-dev:
sudo apt install libMysqLclIEnt-dev
应该解决这个问题。感谢@ thirupathi-thangavel。
我正在尝试启动Django项目。
我在尝试运行manage.py时遇到此错误:
(venv)dyn-160-39-161-214:proj Bren$ python manage.py
TraceBACk (most recent call last):
File "manage.py",line 10,in <module>
execute_from_command_line(sys.argv)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/management/__init__.py",line 354,in execute_from_command_line
utility.execute()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/core/management/__init__.py",line 328,in execute
django.setup()
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/__init__.py",line 18,in setup
apps.populate(setTings.INSTALLED_APPS)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/apps/registry.py",line 108,in populate
app_config.import_models(all_R_139_11845@odels)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/apps/config.py",line 198,in import_models
self.models_module = import_module(models_module_Name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",line 37,in import_module
__import__(Name)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/contrib/auth/models.py",line 41,in <module>
class Permission(models.Model):
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/base.py",line 139,in __new__
new_class.add_to_class('_meta',Options(meta,**kwargs))
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/base.py",line 324,in add_to_class
value.contribute_to_class(cls,Name)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/models/options.py",line 250,in contribute_to_class
self.db_table = truncate_name(self.db_table,connection.ops.max_name_length())
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/__init__.py",line 36,in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS],item)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/utils.py",@R_72_5450@1,in __getitem__
BACkend = load_BACkend(db['ENGINE'])
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/utils.py",line 112,in load_BACkend
return import_module('%s.base' % BACkend_Name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",in import_module
__import__(Name)
File "/Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages/django/db/BACkends/mysql/base.py",line 27,in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % E)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
我想知道应该尝试安装哪个模块。
当我使用时出现pip install MySQLdb
此错误:
CollecTing MySQLdb
Could not find a version that satisfies the requirement MySQLdb (from versions: )
No matching diStribution found for MySQLdb
当我在SO和其他地方查找时,似乎有很多不同的mysql模块。
这也是数据库设置的样子(我没有写这个porject,并且在django和python中是很新的):
DATABASES = {
'default': {
'ENGINE': 'django.db.BACkends.mysql',
&Hellip;
}
}
EdBaker建议 pip install MySQL-python
我得到这个作为回应:
CollecTing MySQL-python Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
TraceBACk (most recent call last):
File "<String>",line 20,in <module>
File "/private/var/folders/m3/11zknyw55zxbw6zqh58rwq580000gn/T/pip-build-DC9tSL/MySQL-python/setup.py",line 17,in <module>
metadata,options = get_config()
File "setup_posix.py",line 43,in get_config
libs = mysql_config("libs_r")
File "setup_posix.py",line 25,in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m3/11zknyw55zxbw6zqh58rwq580000gn/T/pip-build-DC9tSL/MySQL-python
尝试在sHell中运行导入MySQLdb:
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "Help","copyright","credits" or "license" for more information.
>>> import MySQLdb
TraceBACk (most recent call last):
File "<stdin>",line 1,in <module>
ImportError: No module named MySQLdb
尝试升级点数:
pip install pip --upgrade
显示点是最新的
requirement already up-to-date: pip in /Users/Bren/Desktop/fss/venv/lib/python2.7/site-packages
以上是大佬教程为你收集整理的加载MySQLdb模块和“ pip install MySQLdb”时出错全部内容,希望文章能够帮你解决加载MySQLdb模块和“ pip install MySQLdb”时出错所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。