virtualenv、mysql-python、pip:有人知道怎么做吗?
我正在尝试在 virtualenv 中安装 mysql 绑定。我更喜欢使用 pip 或 easy_install。 pip 给我以下错误:
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
easy_install 要么从 sourceforge 获取 404,要么给我一个非常类似的错误。
有谁知道如何在 virtualenv 中解决这个问题?
I'm trying to install the mysql bindings in a virtualenv. I'd prefer to use pip or easy_install. pip gives me the following error:
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
easy_install either gets a 404 from sourceforge or gives me a very similar error.
Does anyone know how to get around this in a virtualenv?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我还尝试在 virtualenv 中设置 MySQL 绑定。我所要做的就是安装包含 mysql_config 的软件包。在 Ubuntu 上,它称为
libmysqlclient-dev
。之后,我能够执行(virtualenv'd)
python setup.py build
和python setup.py install
。I'm also trying to setup MySQL bindings in a virtualenv. All I had to do was install the package that contains mysql_config. On Ubuntu it's called
libmysqlclient-dev
.After that I was able to do a (virtualenv'd)
python setup.py build
andpython setup.py install
.在 OS XI 中,我使用 Macports 安装 MySQL,这使得
mysql_config
文件被称为mysql_config5
。所以我做了:
sudo ln -s mysql_config5 /opt/local/bin/mysql_config
然后从 virtualenv 运行 pip install MySQL-python 一切都很好。
In OS X I had used Macports to install my MySQL, which made the
mysql_config
file be calledmysql_config5
.So I did:
sudo ln -s mysql_config5 /opt/local/bin/mysql_config
And then ran
pip install MySQL-python
from a virtualenv and all was fine.如果您没有安装适当的 mysqlclient-dev 操作系统软件包,您可能根本没有 mysql_config。
就我个人而言,对于需要大量 C 编译的软件包,我更喜欢安装操作系统打包的版本,因为这样我遇到的问题会更少。在我的所有服务器上安装操作系统打包版本的 mysql-python 比安装编译依赖项更容易。
幸运的是,根据我的经验,这些包也往往非常稳定(mysql-python、PIL、lxml 等),因此我不需要在每个项目中对它们进行版本固定。
然而,它确实阻止我使用 virtualenv --no-site-packages,这有点烦人。
You may not have mysql_config at all if you don't have the appropriate mysqlclient-dev OS package installed.
Personally, for packages that require extensive C compilation, I prefer to install OS-packaged versions, as I've had fewer problems that way. It's easier to install the OS-packaged version of mysql-python on all my servers than it is to install the compilation dependencies.
Fortunately in my experience those packages also tend to be very stable (mysql-python, PIL, lxml, etc), so I don't need to version-pin them per-project.
It does, however, prevent me from using virtualenv --no-site-packages, which is a little annoying.
找不到 mysql_config。将包含 mysql_config 的目录放在您的路径上,然后重试。
It is failing to find mysql_config. Put the directory containing mysql_config on your path and try again.