Python/Django 开发,windows 还是 linux?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11338382/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 13:43:14  来源:igfitidea点击:

Python/Django development, windows or linux?

pythonwindowsdjangolinux

提问by Estarius

I have been working on Python quite a lot recently and started reading the doc for Django, however I can't deny the fact that most of the video tutorials I find usually shows Linux as the chosen OS. I've ignored this mostly, but I started to come upon some problems with people using commands such as "touch" for which I have no idea about what the equivalent is in the Windows 7 command prompt. I've heard about New-Item in Power Shell, however it's messy and I am fearing that this "equivalent hunt" might come again and again...

我最近一直在研究 Python 并开始阅读 Django 的文档,但是我不能否认我发现的大多数视频教程通常将 Linux 显示为所选操作系统的事实。我基本上忽略了这一点,但我开始遇到一些问题,人们使用诸如“touch”之类的命令,我不知道 Windows 7 命令提示符中的等价物是什么。我听说过 Power Shell 中的 New-Item,但是它很混乱,我担心这种“等效的狩猎”可能会一次又一次地出现......

So I started to wonder why were most of the people using Linux with Python, would be a good move (knowing that my Linux knowledge is completely null) to learn to use Linux for development purpose? Would it allow me to be more efficient at developing with Python in general? Would it be possible to list the benefits of doing so?

所以我开始怀疑为什么大多数人使用 Linux 和 Python,为了开发目的而学习使用 Linux 会是一个很好的举动(知道我的 Linux 知识完全为零)?一般来说,它能让我更有效地使用 Python 进行开发吗?是否可以列出这样做的好处?

采纳答案by Torsten Engelbrecht

I used Windows for quite some time for Django development, but finally figured out that Linux is simply the better way to go. Here are some reasons why:

我使用 Windows 进行 Django 开发已经有一段时间了,但最终发现 Linux 是更好的选择。以下是一些原因:

  • some Python packages can not be installed at all or correctly in Windows OR it will create a lot of hassle for you to do so
  • if you need to deploy your Django app it makes more sense to use a Unix-flavored system, simply because its 99% likely that you deployment environment is the same. Doing a dry run on your local machine with the same configuration will save you a lot of time later on + here you are "allowed" to make mistakes.
  • If your apps gets complex its way easier in Linux to get the required dependencies, be it extensions, libraries, etc.. In Windows you end up looking for the right site to download everything and go through some hassle of installation and configuration. It took me lots of time to just search for some specific things sometimes. In Linux its often just an "apt-get" (or similiar) and you are done.
  • Did I mention that everything is faster to get and install in Linux?
  • 某些 Python 包根本无法安装或无法在 Windows 中正确安装,否则会给您带来很多麻烦
  • 如果您需要部署 Django 应用程序,使用 Unix 风格的系统更有意义,因为 99% 的可能性您的部署环境是相同的。在具有相同配置的本地机器上进行试运行将在以后为您节省大量时间+在这里您“允许”犯错误。
  • 如果您的应用程序在 Linux 中变得更复杂,以获取所需的依赖项,无论是扩展、库等。有时我花了很多时间来搜索一些特定的东西。在 Linux 中,它通常只是一个“apt-get”(或类似的),你就完成了。
  • 我有没有提到在 Linux 中获取和安装一切都更快?

Of course if your app is simple and you don't need to care about the deployment then Windows is fine.

当然,如果您的应用程序很简单并且您不需要关心部署,那么 Windows 就可以了。

回答by pinkdawn

django is written in pure python, so using Windows + Eclipse + PyDev for development is enough.

django 是纯 python 写的,所以用 Windows + Eclipse + PyDev 开发就够了。

if you really want to follow the cool guys using some Linux commands, then have cygwinor mingWininstalled and set the system PATH to BIN directive. Then, you could use them (include your touch).

如果你真的想使用一些 Linux 命令来跟随那些很酷的人,那么安装cygwinmingWin并将系统路径设置为 BIN 指令。然后,您可以使用它们(包括您的触摸)。

Linux is best choice for deployment of a django project, where you can easily compile / install / configure some cool things like nginx, uWSGI, mod_wsgi, Apache2, and many many useful Python C extensions.

Linux 是部署 django 项目的最佳选择,您可以在其中轻松编译/安装/配置一些很酷的东西,例如 nginx、uWSGI、mod_wsgi、Apache2 和许多有用的 Python C 扩展。

Another reason for using Linux, is that virtual private servers, which are used to host projects, are more likely to support it.

使用 Linux 的另一个原因是用于托管项目的虚拟专用服务器更有可能支持它。

回答by Burhan Khalid

Although there are some benefits in using Linux for Python development (for example, some libraries only work on Linux); there is nothing stopping you from using Windows for djangowork; I use it everyday and nothing has yet to crop up.

尽管使用 Linux 进行 Python 开发有一些好处(例如,某些库只能在 Linux 上运行);没有什么可以阻止您使用 Windows 进行Django工作;我每天都在使用它,而且还没有出现任何问题。

The right IDE that you are comfortable with will go a long way towards making your development experience more enjoyable. Many people use Pydevwith Eclipse; but I prefer PyCharm

您熟悉的正确 IDE 将大大有助于使您的开发体验更加愉快。许多人在 Eclipse 中使用Pydev;但我更喜欢PyCharm

A lot of the tutorials will show you a Linux or Mac desktop (and shell) and you can get the equivalent commands (like touch, lsand others) by installing unixtools- which are native versions of common unix tools.

许多教程将向您展示 Linux 或 Mac 桌面(和 shell),您可以通过安装获得等效的命令(如touchls和其他命令)unixtools——它们是常见 unix 工具的本机版本。

You should bookmark this websitewhich has Windows installers for common Python libraries.

您应该将此网站添加为书签,该网站具有常见 Python 库的 Windows 安装程序。

回答by Efrin

It depends what operating system do you like most. You could use Aptana 3 with pydev(included) for development.

这取决于你最喜欢什么操作系统。您可以使用带有 pydev(included) 的 Aptana 3 进行开发。

When developing remember about use of "os" python lib for paths to dirs, so your application will work correctly under windows and linux.

开发时请记住使用“os”python 库作为目录路径,这样您的应用程序将在 windows 和 linux 下正常工作。

For example:

例如:

PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))

MEDIA_ROOT = os.path.join(PROJECT_DIR, 'site_media')

回答by Raj

I normally use OSX on my desktop, but I use Linux for Python because that's how it will get deployed. Specifically, I use Ubuntu Desktop in a virtual machine to develop Python applications and I use Ubuntu on the server to deploy them. This means that my understanding of library and module requirements/dependencies are 100% transferrable to the server when I'm ready to deploy the application.

我通常在我的桌面上使用 OSX,但我在 Python 上使用 Linux,因为它是这样部署的。具体来说,我在虚拟机中使用 Ubuntu Desktop 来开发 Python 应用程序,并在服务器上使用 Ubuntu 来部署它们。这意味着当我准备好部署应用程序时,我对库和模块要求/依赖项的理解可以 100% 转移到服务器。

If I used OSX (or Windows) to develop Python apps I would have to deal with two different methods of handling requirements and dependencies --- it's just too much work.

如果我使用 OSX(或 Windows)来开发 Python 应用程序,我将不得不处理两种不同的处理需求和依赖项的方法——工作量太大了。

My suggestion: use VMWare Player (it's free) and find a Ubuntu VM to start learning. It's not too complicated and is actually quite fun.

我的建议:使用 VMWare Player(它是免费的)并找到一个 Ubuntu VM 开始学习。它并不太复杂,实际上很有趣。