Permanently set Python path for Anaconda within Cygwin

后端 未结 8 1723
盖世英雄少女心
盖世英雄少女心 2020-12-13 06:32

I\'m trying to install Anaconda on my Windows 7 machine. I often use cygwin to for my command-line work, and I would like to manage Anaconda from there. I\'ve worked through

8条回答
  •  [愿得一人]
    2020-12-13 07:23

    Path

    Regarding your path issue, see Installing anaconda to use with windows on how to fix that. Alternatively, you can just run /cygdrive/c/Anaconda/python.exe to start the Anaconda/windows python and leave the standard python pointing to the cygwin version.

    Note that few of the suggestions given on the internet also include the necessary change to PYTHONPATH: if you use the anaconda/windows python, you also want the anaconda python libraries. Binary modules like numpy will surely crash or misbehave if you mix things up. The easiest way to check this is to install a module in cygwin that you do not need in Conda and test whether you can import that from anaconda python. If you can, your path is wrong.

    Anaconda python will automatically add c:\Anconda to your PYTHONPATH, but if you have it set to serve CYGWIN python libraries, those will be found before the Anaconda libs. Try

    import sys
    sys.path
    

    Terminal

    However, this is also a terminal issue: Anaconda (Windows) python expects a windows shell and a modern cygwin shell is like an xterm, so very different. Diagnose this by running python --help, if that works but plain python hangs, the interactive prompt is the problem. This means you can run python programs, you just cannot interact with them.

    A way around this is to use the cygwin bash shell instead of the cygwin terminal (both are under Cygwin group in the Start menu). They look very similar, but the font in the bash shell is less pretty and you cannot make the window wider than 80 chars (like all other CMD windows, never understood that 'feature'). This is cygwin bash running inside a CMD window, and your anaconda python will be interactive. The cygwin terminal gives you a bash shell running in a putty derivative, which mimics an xterm and cannot be used by anaconda python.

提交回复
热议问题