python - 在 osx for django 的 virtualenv 中安装 mysql

标签 python mysql django macos

我一直在尝试为我的 django 项目安装 mysql。我正在运行 osx yosemite 10.10 和 django=1.7、python 2.7,以及虚拟环境。当我尝试运行 pip install MySQL-python 时出现以下错误:

You are using pip version 6.0.8, however version 7.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
DEPRECATION: --no-install and --no-download are deprecated. See  https://github.com/pypa/pip/issues/906.
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
sh: mysql_config: command not found
 Traceback (most recent call last):
  File "<string>", line 20, in <module>
  File "/Volumes/DiskSecond/pythonsNest/env2/build/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
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 "/Volumes/DiskSecond/pythonsNest/env2/build/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 /Volumes/DiskSecond/pythonsNest/env2/build/MySQL-python

我已经在我的系统上全局安装了 python,但是 django 安装在名为==env2 的虚拟环境中。当我检查我的 env2 的构建文件夹时,已经有一个名为 s 的文件夹,其中包含所有 mysql 文件。但是在使用 pip 安装它时仍然出现错误。问题出在哪里??

最佳答案

您需要在控制台中执行此操作:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后

brew install mysql
pip install mysql-python

关于python - 在 osx for django 的 virtualenv 中安装 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30954647/

相关文章:

django - 如何格式化 django 评论的表单字段?

python - 将参数(目录)传递给 ipython 笔记本中的 %cd 命令

python - MySQL-python 未安装在 virtualenv 中(环境错误 : mysql_config not found)

python - 单个模块/函数等的文档字符串超过 1 个?

python - 更新矩形补丁的位置

mysql - 不确定如何为以下任务构建 SQL 查询

python - 属性错误 : 'MySQLCursor' object has no attribute 'commit'

mysql - Perl mySql 数据到 JSON 文件

python - Django 外键选择字段为空

django - drf-yasg 提供了错误的 URI 路径