python开发环境配置三
更新到Xcode5.1后,在虚拟环境下用pip安装出现各种问题,有Xcode5.1引起的,有其他原因引起的,现在记录下来以便日后不用再到处google。
1.Cannot fetch index base URL https://pypi.python.org/simple/
众所周知的原因,在安装的时候碰到这样的问题可以指定安装源-i http://pypi.douban.com/simpl,完整的命令为:
pip install Fabric -i http://pypi.douban.com/simple
这里用了豆瓣的源。
2.clang: error: unknown argument: ‘-mno-fused-madd’ [-Wunused-command-line-argument-hard-error-in-future]
安装Fabric的时候出现这样的错误,找了半天才在这里找到解决办法。要在安装命令前加上下面的命令:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install GemName
完整的安装命令为:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install Fabric -i http://pypi.douban.com/simple
3.EnvironmentError: mysql_config not found
指定mysql的配置文件
export PATH=$PATH:/usr/local/mysql/bin
然后再执行:
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install MySQL-python -i http://pypi.douban.com/simple
4.使用pod的时候发生下面的错误:
――― MARKDOWN TEMPLATE ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Report * What did you do? * What did you expect to happen? * What happened instead? ### Stack ``` CocoaPods : 0.28.0 Ruby : ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13] RubyGems : 2.0.3 Host : Mac OS X 10.9.2 (13C64) Xcode : 5.1 (5B130a) Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib Repositories : master - https://github.com/CocoaPods/Specs.git @ 3d2a53e79f1e40499ece39a5dbcee2b54ef90aed ``` ### Error ``` Psych::SyntaxError - (/Users/cenphoenix/.cocoapods/repos/master/CocoaPods-version.yml): mapping values are not allowed in this context at line 3 column 4 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:205:in `parse' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:205:in `parse_stream' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:153:in `parse' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:129:in `load' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `block in load_file' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `open' /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `load_file' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/sources_manager.rb:248:in `version_information' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/sources_manager.rb:209:in `repo_compatible?' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/sources_manager.rb:268:in `master_repo_functional?' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/command.rb:40:in `parse' /Library/Ruby/Gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:186:in `parse' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/command.rb:39:in `parse' /Library/Ruby/Gems/2.0.0/gems/claide-0.4.0/lib/claide/command.rb:211:in `run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/lib/cocoapods/command.rb:52:in `run' /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.28.0/bin/pod:24:in `解决办法:
1)删除cocoapods
sudo rm -fr ~/.cocoapods/repos/master
2)重新安装
pod setup
但是发生下面的错误:
Setting up CocoaPods master repo [!] The `master` repo requires CocoaPods 0.29.0 - Update CocoaPods, or checkout the appropriate tag in the repo.
3)运行下面命令:
sudo gem update cocoapods
4)最后运行:
pod setup
5.在django上添加上传文件的时候,发生下面的错误:
_("Neither Pillow nor PIL could be imported: %s") % err django.core.exceptions.ImproperlyConfigu
从错误看应该是未安装PIL或者Pillow,Image等包。
安装Pillow
pip install Pillow
发生下面错误
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
# include
1 解决办法是: 1^ 1 error generated. error: command 'cc' failed with exit status 1 ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
sudo pip install pil