如何集成Django和Cygwin?

发布于 2024-07-13 14:52:31 字数 245 浏览 7 评论 0原文

我有一个安装了 cygwin、python 和 django 的 Windows 盒子。

现在我想运行 django-admin,但是当我这样做时,我收到错误:

$ django-admin.py
c:\Python26\python.exe: can't open file '/usr/bin/django-admin.py': [Errno 2] No such file or directory

I have a Windows box with cygwin, python and django installed.

Now I want to run django-admin, but when I do I get the error:

$ django-admin.py
c:\Python26\python.exe: can't open file '/usr/bin/django-admin.py': [Errno 2] No such file or directory

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

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

发布评论

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

评论(9

够运 2024-07-20 14:52:31

来自此处

对于没有可用符号链接功能的 Windows 用户,您可以将 django-admin.py 复制到现有路径上的某个位置或编辑 PATH 设置(在设置 - 控制面板 - 系统 - 高级 - 环境下... ) 指向其安装位置。

希望这可以帮助

From here

For Windows users, who do not have symlinking functionality available, you can copy django-admin.py to a location on your existing path or edit the PATH settings (under Settings - Control Panel - System - Advanced - Environment...) to point to its installed location.

hope this helps

墟烟 2024-07-20 14:52:31

我刚刚遇到了完全相同的问题。 我发现如果你已经安装了 windows 版本的 python,它似乎优先于 cygwin 版本。 我通过编辑 /etc/profile 解决了这个问题,并将:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH

...更改为:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:

...我认为这会阻止 cygwin 添加正常的 Windows 路径。 一旦你完成了这个工作,将 django 下载到某个目录中,进入该目录并输入:

python setup.py install

我一开始就遇到了问题,因为我在开始时省略了“python”位

I just ran into the exact same problem. I've found that if you already have the windows version of python installed, it seems to get priority over the cygwin version. I solved the problem by editing /etc/profile and changed:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:$PATH

...to:

PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:

...which I think stops cygwin from adding the normal windows path. Once you've got that working, download django into some directory, move into that directory and type:

python setup.py install

I was having problems to begin with because I had omitted the 'python' bit at the start

花辞树 2024-07-20 14:52:31

至于如何在 cygwin 中启动 django 的步骤

首先打开 Windows 命令提示符
然后通过这样做注册python环境:

Path %path%;C:\Python27;C:\Python27\Scripts

然后现在转到cygwin的安装文件夹

cd C:\cygwin

然后运行cygwin.bat,如下所示:

C:\cygwin>cygwin.bat    <enter>

然后cygwin将打开,并输入python看看它现在是否正常工作

$ python

瞧,我们就完成了!

As for the step on how to start your django in cygwin

first open your windows command prompt
then register the python environment by doing this:

Path %path%;C:\Python27;C:\Python27\Scripts

then now go to the installation folder of your cygwin

cd C:\cygwin

then run the cygwin.bat like this:

C:\cygwin>cygwin.bat    <enter>

then cygwin will open, and type python to see if it now working

$ python

Voila we are done!

冷情妓 2024-07-20 14:52:31

听起来有点像 Windows 版本的 Python 正在尝试运行而不是 cygwin 版本。 如果您输入以下内容会发生什么:

$ python django-admin.py

这里我假设

$ which python

找到 python 的 cygwin 版本(类似于 /usr/bin/python)。

您也可以尝试(暂时)卸载 Windows 版本的 python 并仅使用 cygwin。

Sort of sounds like the windows version of Python is trying to run instead of the cygwin one. What happens if you type this:

$ python django-admin.py

Here I'm assuming

$ which python

Finds the cygwin version of python (which will be something like /usr/bin/python).

You may also try (temporarily) uninstalling the windows version of python and use only cygwin.

一场信仰旅途 2024-07-20 14:52:31

帮助我们帮助你。 您运行 Windows python 解释器 (c:\Python26\python.exe) 而不是 cygwin python 解释器 (/usr/bin/python.exe) 是否有原因? 那可能是你的问题。 因此,要解决此问题,您可以考虑删除 Windows 本机解释器,或者只是确保 cygwin 路径列在 Windows 全局 PATH 变量中的 c:\Python26 路径之前。

Help us help you. Is there a reason why you are running the windows python interpreter (c:\Python26\python.exe) as oppose to the cygwin python interpreter (/usr/bin/python.exe)? That could be your problem. So to troubleshoot that, you might consider removing the windows native interpreter or simply making sure the cygwin path is listed before the c:\Python26 path in the windows global PATH variable.

安静 2024-07-20 14:52:31

将 django/bin 文件夹的位置(或保存 django-admin.py 的其他位置)添加到 PYTHONPATH 环境变量中。

Add the location of your django/bin folder (or wherever else you keep django-admin.py) to your PYTHONPATH environment variable.

风情万种。 2024-07-20 14:52:31

就像 Brian 提到的,您正在运行 Windows 版本的 Python,它无法与 Cygwin 安装一起使用。

一句警告。 当我第一次开始使用 Django 时,我尝试将其安装在 Cygwin 中,但遇到了各种问题,最终切换到了常规 Windows 版本的 Python。 不幸的是,我没有记录所有问题,但我记得其中一些与数据库有关。 不管怎样,那是几个月前的事了,当时我对 Django 的了解还不如现在。 也许我遇到的问题已经解决了,也许现在我知道了更多,我可以让它工作,但在 Cygwin 上运行 Django 似乎确实是一条少有人走的路。 祝你好运。 :)

Like Brian mentioned you are running the Windows version of Python which won't work with the Cygwin installation.

A word of warning. When I first started using Django, I tried installing it in Cygwin and had a variety of problems and ended up switching to the regular Windows version of Python. Unfortunately, I didn't document all my issues, but I remember some of them had to do with the database libraries. Anyway, that was a few months ago when I knew less about Django than I do now. Maybe the problems I ran into have been solved and perhaps now that I know more I could get it to work, but running Django on Cygwin does seem to be the road less traveled. Good luck. :)

那伤。 2024-07-20 14:52:31

只需将 django-admin.py 复制到您正在处理的当前位置,例如

在 Cygwin 上:

<root>/projects/

在您的 Windows 目录中,它将如下所示:

C:\cygwin\home\<your computer name>\projects\

复制文件后,您可以通过以下方式创建项目输入此命令:

$ python django-admin.py startproject mysite

就这样 - 您已经使用 Cygwin 类似 Linux 的环境完成了您的第一个项目。

Just copy the django-admin.py to the current location you are working on for e.g

on Cygwin:

<root>/projects/

on your windows directory it will look like this:

C:\cygwin\home\<your computer name>\projects\

once you copy the file, you can create your project by typing this command:

$ python django-admin.py startproject mysite

and that's all - you have completed your first project using the Cygwin linux-like environment.

蓝眼泪 2024-07-20 14:52:31

.bash_profile.bashrc 文件中添加两行(查看它们的区别此处)。 您可以在 C:\cygwin\home\[用户名] 中找到它们:

export PATH=$PATH:/cygdrive/c/python2.7
export PYTHONPATH=$PYTHONPATH:/cygdrive/c/python2.7/Lib/site-packages

希望这会有所帮助

Add two lines to .bash_profile and .bashrc files (view their difference here). You can find them in C:\cygwin\home\[username]:

export PATH=$PATH:/cygdrive/c/python2.7
export PYTHONPATH=$PYTHONPATH:/cygdrive/c/python2.7/Lib/site-packages

Hope this helps

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