区块链技术博客
www.b2bchain.cn

在Mac上安装MySQL-python – python程序员分享

本文介绍了在Mac上安装MySQL-python – python程序员分享,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

我正在使用OSX 10.8和PyCharm进行Python开发项目。我已经按照网站上的说明为Mac安装了MySQL-python

http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found

但是,运行项目会给我这个错误:

django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows   Referenced from: /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so   Expected in: flat namespace  in /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so 

错误中提到的文件存在于-Users / ashishagarwal / .python-eggs / MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp / _mysql.so

整个错误消息是-

/usr/local/bin/python2.7-32 /Users/ashishagarwal/Optimus/MashPotato/backend/mashpotato/manage.py testserver --addrport 8000 Running on development server Traceback (most recent call last):   File "/Users/ashishagarwal/Optimus/MashPotato/backend/mashpotato/manage.py", line 10, in <module>     execute_from_command_line(sys.argv)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line     utility.execute()   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute     self.fetch_command(subcommand).run_from_argv(self.argv)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command     klass = load_command_class(app_name, subcommand)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class     module = import_module('%s.management.commands.%s' % (app_name, name))   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module     __import__(name)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/south/management/commands/__init__.py", line 10, in <module>     import django.template.loaders.app_directories   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loaders/app_directories.py", line 23, in <module>     mod = import_module(app)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module     __import__(name)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 3, in <module>     from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/helpers.py", line 4, in <module>     from django.contrib.admin.util import (flatten_fieldsets, lookup_field,   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/util.py", line 6, in <module>     from django.db import models   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 40, in <module>     backend = load_backend(connection.settings_dict['ENGINE'])   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__     return getattr(connections[DEFAULT_DB_ALIAS], item)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 93, in __getitem__     backend = load_backend(db['ENGINE'])   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/utils.py", line 27, in load_backend     return import_module('.base', backend_name)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module     __import__(name)   File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>     raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows   Referenced from: /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so   Expected in: flat namespace  in /Users/ashishagarwal/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so  Process finished with exit code 1 

参考方案

您应该首先通过Homebrew安装MySQL,以使python-mysql在OS X上正常工作。

pip uninstall MySQL-python brew install mysql pip install MySQL-python 

在Python中,我正在使用uuid4()方法创建唯一的字符集。但是我找不到将其限制为10或8个字符的方法。有什么办法吗?uuid4()ffc69c1b-9d87-4c19-8dac-c09ca857e3fc谢谢。 参考方案 尝试:x = uuid4() str(x)[:8] 输出:"ffc69c1b" Is there a way to…

我正在开发用于访问Redis Server的Python服务(类)。我想知道如何检查Redis Server是否正在运行。而且如果某种原因我无法连接到它。这是我的代码的一部分import redis rs = redis.Redis("localhost") print rs 它打印以下内容<redis.client.Redis o…

我很难理解如何使用单个CBV处理(至少)2种不同情况。这是我想做的事情:我有一个ListView来显示对象列表。从那里,我生成一个链接以导航到DetailView以显示对象的详细信息。从那里,我生成一个链接到呈现相关报告的不同视图。我想使用以下网址:1. /myapp/list.html/ 2. /myapp/detail.html/<<uuid…

我正在尝试在Linux OS(CentOS 7)上使用Python-crontab模块我的配置文件如下:{ "ossConfigurationData": { "work1": [ { "cronInterval": "0 0 0 1 1 ?", "attribute&…

我有一个Python脚本在某些深度学习模型上运行推理。有什么办法可以找出GPU资源的利用率水平?例如,使用着色器,float16乘法器等。我似乎在网上找不到太多有关这些GPU资源的文档。谢谢! 参考方案 您可以尝试在像Renderdoc这样的GPU分析器中运行pyxthon应用程序。它将分析您的跑步情况。您将能够获得有关已使用资源,已用缓冲区,不同渲染状态上…

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » 在Mac上安装MySQL-python – python程序员分享
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们