在OSX 10.6上为Python安装MySQLdb - 创建.egg时出错
我在Snow Leopard上运行的是32位的Python 2.7,安装了64位的MySQL,以避免不同位数之间的冲突。不过,我在安装MySQLdb时还是遇到了问题。
我按照这个和其他一些网上的指南操作,但还是没有进展。安装时我看到的输出是:
$ ARCHFLAGS='-arch x86_64' python setup.py install
running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-x86_64/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-x86_64-2.7/MySQLdb
running build_ext
copying build/lib.macosx-10.6-x86_64-2.7/MySQLdb/release.py -> build/bdist.macosx-10.6-x86_64/egg/MySQLdb
byte-compiling build/bdist.macosx-10.6-x86_64/egg/MySQLdb/release.py to release.pyc
creating stub loader for _mysql.so
byte-compiling build/bdist.macosx-10.6-x86_64/egg/_mysql.py to _mysql.pyc
copying MySQL_python.egg-info/PKG-INFO -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying MySQL_python.egg-info/top_level.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.6-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/MySQL_python-1.2.3-py2.7-macosx-10.6-x86_64.egg' and adding 'build/bdist.macosx- 10.6-x86_64/egg' to it
error: dist/MySQL_python-1.2.3-py2.7-macosx-10.6-x86_64.egg: Permission denied
有没有人知道我哪里出错了?
1 个回答
0
很可能你曾经在使用 sudo
命令运行 python setup.py
的时候,导致现在你的 dist
文件夹属于根用户(root)。你需要先清空你构建目录下的 dist
子文件夹,然后再重新运行:
sudo rm -rf ./dist
ARCHFLAGS='-arch x86_64' python setup.py install
如果在最后的安装步骤中出现权限错误,你可能需要在 sudo
下运行 install
步骤:
sudo bash
export ARCHFLAGS='-arch x86_64'
/path/to/same/python2.7 setup.py install
exit
不过,如果没有必要的话,最好还是不要这样做。