【问题标题】:installing mysql in virtualenv on osx for django在 django 的 osx 上的 virtualenv 中安装 mysql
【发布时间】:2015-09-06 09:51:48
【问题描述】:

我一直在尝试为我的 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 的 virtualenv 中。当我检查我的 env2 的构建文件夹时,已经存在一个名为 s 的文件夹,其中包含所有 mysql 文件。但是使用 pip 安装它时仍然出现错误。问题出在哪里??

【问题讨论】:

标签: python mysql django macos


【解决方案1】:

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

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

然后

brew install mysql
pip install mysql-python

【讨论】:

  • 我正在为 django 运行它,那么 ruby​​ 命令是如何工作的呢?当我尝试运行 brew install mysql 时,它显示了一个错误。
  • 他需要获得与 CentOS / RHEL 的 mysql-devel 包或 Ubuntu/Debian 的 libmysqlclient-dev 等效的软件包,除非 brew 处理所有这些?
  • 另外,我已经为 mysql 和 phpmyadmin 安装了 xampp ..所以有可能正因为如此,出现了提到的错误。我也尝试找到我的 mysqld 文件,当我尝试直接从 xampp 应用程序递归列出它时它会显示,但是当我尝试运行它时,它根本没有出现?
猜你喜欢
  • 2014-02-07
  • 2012-09-11
  • 2016-02-13
  • 2015-08-18
  • 2013-08-27
  • 1970-01-01
  • 2014-08-25
  • 1970-01-01
  • 2012-07-27
相关资源
最近更新 更多