如何集成Django和Cygwin?
我有一个安装了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
来自此处
希望这可以帮助
From here
hope this helps
我刚刚遇到了完全相同的问题。 我发现如果你已经安装了 windows 版本的 python,它似乎优先于 cygwin 版本。 我通过编辑 /etc/profile 解决了这个问题,并将:
...更改为:
...我认为这会阻止 cygwin 添加正常的 Windows 路径。 一旦你完成了这个工作,将 django 下载到某个目录中,进入该目录并输入:
我一开始就遇到了问题,因为我在开始时省略了“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:
...to:
...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:
I was having problems to begin with because I had omitted the 'python' bit at the start
至于如何在 cygwin 中启动 django 的步骤
首先打开 Windows 命令提示符
然后通过这样做注册python环境:
然后现在转到cygwin的安装文件夹
然后运行cygwin.bat,如下所示:
然后cygwin将打开,并输入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:
then now go to the installation folder of your cygwin
then run the cygwin.bat like this:
then cygwin will open, and type python to see if it now working
Voila we are done!
听起来有点像 Windows 版本的 Python 正在尝试运行而不是 cygwin 版本。 如果您输入以下内容会发生什么:
这里我假设
找到 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:
Here I'm assuming
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.
帮助我们帮助你。 您运行 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.
将 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.
就像 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. :)
只需将 django-admin.py 复制到您正在处理的当前位置,例如
在 Cygwin 上:
在您的 Windows 目录中,它将如下所示:
复制文件后,您可以通过以下方式创建项目输入此命令:
就这样 - 您已经使用 Cygwin 类似 Linux 的环境完成了您的第一个项目。
Just copy the django-admin.py to the current location you are working on for e.g
on Cygwin:
on your windows directory it will look like this:
once you copy the file, you can create your project by typing this command:
and that's all - you have completed your first project using the Cygwin linux-like environment.
在
.bash_profile
和.bashrc
文件中添加两行(查看它们的区别此处)。 您可以在C:\cygwin\home\[用户名]
中找到它们:希望这会有所帮助
Add two lines to
.bash_profile
and.bashrc
files (view their difference here). You can find them inC:\cygwin\home\[username]
:Hope this helps