我也在我的Mac上做Django開發,但已經找到了一個更好的解決方案(它允許使用pip)來使用Vagrant + VirtualBox + Chef在本地VM中安裝Django(這將允許您複製生產服務器設置)。然後您可以在本地瀏覽器上訪問它。有一個很好的介紹在這裏:
http://blog.smalleycreative.com/tutorials/setup-a-django-vm-with-vagrant-virtualbox-and-chef/
我已經更新到本教程提供使用precise32(留在人誰可能是在32位系統兼容),一個新的Ubuntu發行版的vagrantfile,幷包括emacs,python和MySQL客戶端。我希望這有幫助。必要
其他的git回購協議:
git clone git://github.com/opscode-cookbooks/emacs
git clone git://github.com/opscode-cookbooks/python
git clone git://github.com/opscode-cookbooks/mysql
而且Vagrantfile:
Vagrant::Config.run do |config|
config.vm.define :djangovm do |django_config|
# Every Vagrant virtual environment requires a box to build off of.
django_config.vm.box = "precise32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
django_config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# Forward a port from the guest to the host, which allows for outside
# computers to access the VM, whereas host only networking does not.
django_config.vm.forward_port 80, 8080
django_config.vm.forward_port 8000, 8001
# Enable provisioning with chef solo, specifying a cookbooks path (relative
# to this Vagrantfile), and adding some recipes and/or roles.
#
django_config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "apt"
chef.add_recipe "apache2::mod_wsgi"
chef.add_recipe "build-essential"
chef.add_recipe "git"
chef.add_recipe "vim"
chef.add_recipe "emacs"
chef.add_recipe "python"
chef.add_recipe "mysql"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
end
end
end
感謝您的提示。現在我只是得到一個錯誤,因爲我已經安裝了一個pip版本:Error:org.macports.activate for port py27-pip returned:Image error:/opt/local/Library/Frameworks/Python.framework/Versions/2.7/ bin/pip已經存在,並且不屬於註冊的端口。無法激活端口py27-pip。使用'port -f activate py27-pip'強制激活。在Linux上,我通常會執行sudo apt-get purge pip(或類似操作),但是如何在OSX上卸載現有的pip? – kramer65 2013-05-15 02:58:22
不幸的是,你沒有通過macports安裝它,因此'不屬於註冊的端口'只是強制激活它將覆蓋它 – Mark 2013-05-15 09:59:36
不幸的是,這仍然不起作用。我做了'sudo port -f install py27-pip',然後'sudo pip install web.py'再次導致「Requirement already satisfied」,而在Python交互式命令行中導入web仍然給我一個「ImportError:No模塊名爲web「。任何其他想法? – kramer65 2013-05-15 15:05:21