简体   繁体   English

Cygwin和Windows路径冲突; 同时使用 Windows 和 cygwin Python

[英]Cygwin and Windows path conflict; using both Windows and cygwin Python

I've installed cygwin on Windows XP.我已经在 Windows XP 上安装了 cygwin。 Mercurial on cygwin stopped working after I installed some software on Windows.我在 Windows 上安装了一些软件后,cygwin 上的 Mercurial 停止工作。 The symptom can be simplified to python not being able to locate modules in its library:症状可以简化为 python 无法在其库中找到模块:

>>> import os
Traceback (most recent call last):
  file "<stdin>", line 1, in <module>
ImportError: No module named os

One of the pieces of software I installed in Windows (subversion) uses python so now Windows has its own Python installation.我在 Windows (subversion) 中安装的软件之一使用 python 所以现在 Windows 有自己的 ZA7F5F35426B9274117FC923 安装。 Don't ask why I wish to use mercurial under cygwin and subversion under Windows;别问我为什么要在cygwin下用mercurial,在Windows下用subversion; suffice to say I do, but that's beside the point.我只想说我愿意,但这无关紧要。 It seems cygwin tries to use the Windows python instead of its own, or at least that's what I think is happening. cygwin 似乎试图使用 Windows python 而不是自己的,或者至少我认为这是正在发生的事情。 If that's not the cause, please enlighten me.如果不是这个原因,请赐教。 Anyway...反正...

$ find /cygdrive/c -name os.py /cygdrive/c/csvn/Python25/Lib/os.py /cygdrive/c/cygwin/lib/python2.6/os.py $ find /cygdrive/c -name os.py /cygdrive/c/csvn/Python25/Lib/os.py /cygdrive/c/cygwin/lib/python2.6/os.py

echo $PATH confirms that /cygdrive/c/csvn/Python25 is before /usr/lib/python2.6. echo $PATH 确认 /cygdrive/c/csvn/Python25 在 /usr/lib/python2.6 之前。 I'm no cygwin wiz, but from what I can tell /etc/profile adds the Windows path to cygwin's $PATH, and I don't know how to keep it from doing so.我不是 cygwin wiz,但据我所知 /etc/profile 将 Windows 路径添加到 cygwin 的 $PATH 中,我不知道如何阻止它这样做。 As a workaround I modified.profile to explicitly set PATH, excluding those paths from Windows.作为一种解决方法,我修改了.profile 以显式设置 PATH,不包括来自 Windows 的那些路径。 But, the problem remains:但是,问题依然存在:

$ echo $PATH
/usr/local/bin:/usr/bin:/usr/lib/python2.6
$ hg
'import site' failed; use -v for traceback
Traceback (most recent call last):
  File "/usr/bin/hg", line 10, in <module>
    import os
ImportError: No module named os

$ ls /usr/lib/python2.6/os.py
/usr/lib/python2.6/os.py

It looks like the path conflict has not actually been resolved, because when I issue the above "find" command again I get the same results, with /cygdrive/c/csvn/Python25/Lib/os.py showing up first.看起来路径冲突实际上并没有得到解决,因为当我再次发出上述“查找”命令时,我得到了相同的结果,首先出现的是 /cygdrive/c/csvn/Python25/Lib/os.py。 In theory there may be some other reason python isn't working on cygwin, but not being able to control my PATH would still be a problem.从理论上讲,python 无法在 cygwin 上运行可能还有其他原因,但无法控制我的 PATH 仍然是个问题。 Any ideas?有任何想法吗?

Unfortunately my colleague who also had the problem already uninstalled the csvn thing, so I can't check.不幸的是,我同样遇到问题的同事已经卸载了 csvn 的东西,所以我无法检查。 But reading the doc suggests the culpable variable might be $PYTHONHOME .但是阅读文档表明有罪的变量可能是$PYTHONHOME Check whether it's set and try unsetting it!检查它是否已设置并尝试取消设置!

Have you tried the solutions found in this other SO post ?您是否尝试过在其他 SO 帖子中找到的解决方案? Seems like a similar problem.似乎是一个类似的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM