Django - Mac 开发,环境地狱

发布于 2024-11-19 03:25:20 字数 555 浏览 2 评论 0原文

我试图在 Mac 上设置 Django 开发环境,结果陷入了困境。这一切都是从尝试安装 PIL 开始的,在尝试了我在博客上找到的大约 15 个不同的食谱后,它失败了。所以我想安装Python,这次是2.7,并从头开始重新安装setuptools、easy_install、pip。

在刚刚安装了 Python 2.7 以及 2.7 的 easy_install 和 setuptools 之后,这一切又造成了令人难以置信的混乱。到处都安装了不同版本的Python,到处都安装了easy_install,并随机指向不同的python hashbang(有时指向#!/usr/bin、#!/usr/local/、#!/Library/...)

现在我可以了甚至不做 easy_install pip,我总是可以。所以我已经陷入困境了,我什至还没有尝试安装MySQL。

最后我的问题是有人遇到过这样的问题吗?知道我并不孤单会很有帮助。

其次,在Ubuntu上设置整个环境会比在Mac上更容易吗?

第三,是否有任何指南可以真正清楚地解释如何在 Mac 上设置和拆卸 Python 开发堆栈?

I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.

After just installing Python 2.7, and easy_install with setuptools for 2.7, this all in turn created such a mess that is unbelievable. Different version of Python are installed everywhere, easy_install is installed everywhere and points randomly to different python hashbangs (sometimes to #!/usr/bin, #!/usr/local/, #!/Library/...)

Now I can't even do easy_install pip, which I always could. So I'm already in a hell and I haven't even attempted to install MySQL yet.

My question finally is did anyone bump into such problems, it would help enough to know that I'm not alone.

Second, would it be easier to set up the entire environment on Ubuntu than it is on a Mac?

Thirdly, is there any guide that can really clearly explain how to set up but also tear down the stack for Python development on a Mac?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

木緿 2024-11-26 03:25:20

使用 vagrant 运行虚拟机不会有什么坏处。这篇文章应该告诉你更多:
http://stevelosh.com/blog/2011/06/django-advice/

当然,使用 virtualenv 也应该有助于缓解其中一些问题。

It wouldn't hurt to run a VM with vagrant. This post should tell you more:
http://stevelosh.com/blog/2011/06/django-advice/

Of course using virtualenv should also help alleviate some of these issues.

一场信仰旅途 2024-11-26 03:25:20

两周前我也经历过同样的地狱:)

我需要在 OSX 10.6.8 上运行 python 2.7 和 virtualenv。
您在问题中没有提到 virtualenv,但我强烈推荐它。这样您就可以最大限度地减少全局安装的软件包的数量。一切都……更干净了。
我的想法是只在全球范围内拥有以下内容:

  • python (来自brew)
  • pip (通过 easy_install)
  • virtualenv (通过 pip)
  • virtualenvwrapper (通过 pip)
  • 其他通过 virtualenv 或 buildout

我刚刚检查过, pip PIL 在我的 virtualenv 中安装得很好。

以下是这场战斗的笔记 (gist.github.com):

#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs

示例 .bash_profile:

#homebrew
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}

# homebrew python 2.7
export PATH="/usr/local/share/python:${PATH}"

#virtualenv wrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh

祝你好运!

I've gone through the same hell 2 weeks ago :)

I needed to make working python 2.7 and virtualenv on OSX 10.6.8.
You haven't mentioned virtualenv in your question but I strongly recommend it. That way you minimize amount of globally installed packages. Everything is... cleaner.
My idea is to only have following things globally:

  • python (from brew)
  • pip (via easy_install)
  • virtualenv (via pip)
  • virtualenvwrapper (via pip)
  • other through either virtualenv or buildout

I've just checked and pip PIL installs fine within my virtualenv.

Here are notes from this battle (gist.github.com):

#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs

Example .bash_profile:

#homebrew
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}

# homebrew python 2.7
export PATH="/usr/local/share/python:${PATH}"

#virtualenv wrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh

Good luck!

深海夜未眠 2024-11-26 03:25:20

第二,设置起来会不会更容易一些
Ubuntu上的整个环境比
它是在 Mac 上吗?

回答这个问题(尽管我从未使用过 Mac):在 Ubuntu 上为 Django 开发设置 python 环境时从来没有遇到过问题。但无论如何,如果可能的话,您应该使用内置的 Python 版本。尝试安装任何其他 Python 版本通常会导致混乱。幸运的是,Ubuntu 11.04 的标准版本已经是 2.7。

Second, would it be easier to set up
the entire environment on Ubuntu than
it is on a Mac?

To answer this question (though I never used Mac though): I never had problems setting up a python environment for Django development on Ubuntu. Though in any case you should go with the built-in Python version if possible. Attempting to install any other Python versions usually ends up messy. Luckily with Ubuntu 11.04 the standard version is already 2.7.

一曲琵琶半遮面シ 2024-11-26 03:25:20

我在 MAC OS X 10.8 和 python 2.7 上使用 django 开发环境。我不使用 virtualenv 或其他一些东西。

恕我直言,在 Mac 上开发没有任何问题。 Mac 是一个类似 UNIX 的系统,您可能已经看到所有供开发人员使用的工具都有 MAC 端口。

至于设置混乱。使用 virtualenv 是个好主意。至于PIL安装。我需要用 TrueType 来编译它。由于我与 UNIX 等环境相同,因此使用 GCC 从源代码编译 PIL 对我来说并不是一项繁重的任务(它已经安装在 MAC 上)...使用 Django 设置 virtualenv 时有些混乱...当然有谷歌上有很多关于设置它的文章。

我使用 Eclipse 并在那里写入所有 PYTHONPATH 变量。您可以像在 Linux 中那样忘记安装所有内容,并尽量不要再弄乱已安装的工具。如果您有以下情况,请尝试阅读这篇文章感觉你可以在 MAC 上使用 Eclipse 进行开发。它还提供了避免安装许多 Python 副本和其他开发实用程序时出现混乱的方法。

I'm using django development environment on a MAC OS X 10.8 with python 2.7. I don't use virtualenv ore some other things.

With all the respect can say that there is NO ANY PROBLEMS to develop on a mac. Mac is a UNIX like system and you've probably seen that all tools for developers have MAC ports.

As for the setup mess. It's a good idea to use virtualenv. As for PIL installation. I needed to compile it with TrueType. As I'm in common with UNIX like environments it was not heavy task for me to compile PIL from sources using GCC (it's already installed on a MAC)... There are some mess with Django to setup virtualenv... There are certainly lots of articles to setup it on Google.

I use Eclipse and write all my PYTHONPATH variables there. You can forget installing everything like in Linux and try not to make anymore mess with installed tools. Try to read THIS article if you feel like you're ok to use Eclipse for your development on a MAC. It also has a recipe to avoid mess with installation of many copies of Python and other dev utils.

巷子口的你 2024-11-26 03:25:20

是的,我在使用 MacOS 时遇到了问题。我想我并没有试图弄清楚它,而是切换到了 Ubuntu。我使用的是在 VMware Fusion 中安装了 Ubuntu 的 Mac。我在两者上都进行过开发,并且更喜欢 Ubuntu,因为我更喜欢安装软件包和文件结构。

我喜欢使用虚拟机,因为我从不害怕重新开始。我可以在短短几个小时内安装一个全新的操作系统并获取我使用的软件包。更不用说 6 个月的推出,我可以完成新版本的安装而不是更新。

根据您的生产环境,使用类似的操作系统可能会有所帮助,如果您可以在 ubuntu 桌面上安装软件包,那么您已经知道如何在 ubuntu 服务器上执行此操作。

Yes I have had problems with MacOS. I think rather than trying to figure it out I just switched to Ubuntu. I use a mac with Ubuntu installed in VMware Fusion. I have developed on both and prefer the Ubuntu because I'm just more comfortable with installing packages and the file structure.

I love using the VM because I'm never scared of having to start over. I can get a whole new OS installed and get the packages with what I use in just a few hours. Not to mention with 6month rollouts I can do complete installs of new versions instead of updates.

Depending on your production environment, it may be beneficial to use an OS that is similar, if you can install a package on ubuntu desktop, you already know how to do it on ubuntu server.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文