問題描述
我正在嘗試在我的 Windows 7 機器上安裝 Anaconda.我經常使用 cygwin 來進行命令行工作,我想從那里管理 Anaconda.我已經完成了圖形安裝程序,沒有任何問題,并選中了必要的框以將我的默認路徑重置為此 python 安裝.我繼續檢查 python 在哪里,最初我得到了這個......
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 the graphic installer without any issues, and checked necessary boxes to reset my default path to this install of python. I go ahead to check where python is and initially I get this...
$ which python
/usr/bin/python
從這里 python 工作正常...
From here python works fine...
$ python
Python 2.7.5 (default, Oct 2 2013, 22:34:09)
[GCC 4.8.1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
但我正在嘗試從 anaconda 工作,所以我只需要重新定義我的路徑...
But I'm trying to work from anaconda, so I should just need to redefine my path...
$ export PATH=/cygdrive/c/anaconda:$PATH
$ which python
/cygdrive/c/anaconda/python
現在我應該很好了,但是當我嘗試進入 python 時,它只是掛起
And now I should be good to go, but when I try and step into python, it just hangs
$ python
知道為什么會發生這種情況嗎?詳細返回,下面...
Any idea why this might be happening? verbose return, below...
$ python -v
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# C:anacondalibsite.pyc matches C:anacondalibsite.py
import site # precompiled from C:anacondalibsite.pyc
# C:anacondalibos.pyc matches C:anacondalibos.py
import os # precompiled from C:anacondalibos.pyc
import errno # builtin
import nt # builtin
# C:anacondalib
tpath.pyc matches C:anacondalib
tpath.py
import ntpath # precompiled from C:anacondalib
tpath.pyc
# C:anacondalibstat.pyc matches C:anacondalibstat.py
import stat # precompiled from C:anacondalibstat.pyc
# C:anacondalibgenericpath.pyc matches C:anacondalibgenericpath.py
import genericpath # precompiled from C:anacondalibgenericpath.pyc
# C:anacondalibwarnings.pyc matches C:anacondalibwarnings.py
import warnings # precompiled from C:anacondalibwarnings.pyc
# C:anacondaliblinecache.pyc matches C:anacondaliblinecache.py
import linecache # precompiled from C:anacondaliblinecache.pyc
# C:anacondalib ypes.pyc matches C:anacondalib ypes.py
import types # precompiled from C:anacondalib ypes.pyc
# C:anacondalibUserDict.pyc matches C:anacondalibUserDict.py
import UserDict # precompiled from C:anacondalibUserDict.pyc
# C:anacondalib\_abcoll.pyc matches C:anacondalib\_abcoll.py
import _abcoll # precompiled from C:anacondalib\_abcoll.pyc
# C:anacondalibabc.pyc matches C:anacondalibabc.py
import abc # precompiled from C:anacondalibabc.pyc
# C:anacondalib\_weakrefset.pyc matches C:anacondalib\_weakrefset.py
import _weakrefset # precompiled from C:anacondalib\_weakrefset.pyc
import _weakref # builtin
# C:anacondalibcopy_reg.pyc matches C:anacondalibcopy_reg.py
import copy_reg # precompiled from C:anacondalibcopy_reg.pyc
# C:anacondalib raceback.pyc matches C:anacondalib raceback.py
import traceback # precompiled from C:anacondalib raceback.pyc
# C:anacondalibsysconfig.pyc matches C:anacondalibsysconfig.py
import sysconfig # precompiled from C:anacondalibsysconfig.pyc
# C:anacondalib
e.pyc matches C:anacondalib
e.py
import re # precompiled from C:anacondalib
e.pyc
# C:anacondalibsre_compile.pyc matches C:anacondalibsre_compile.py
import sre_compile # precompiled from C:anacondalibsre_compile.pyc
import _sre # builtin
# C:anacondalibsre_parse.pyc matches C:anacondalibsre_parse.py
import sre_parse # precompiled from C:anacondalibsre_parse.pyc
# C:anacondalibsre_constants.pyc matches C:anacondalibsre_constants.py
import sre_constants # precompiled from C:anacondalibsre_constants.pyc
# C:anacondaliblocale.pyc matches C:anacondaliblocale.py
import locale # precompiled from C:anacondaliblocale.pyc
import encodings # directory C:anacondalibencodings
# C:anacondalibencodings\__init__.pyc matches C:anacondalibencodings\__init__.py
import encodings # precompiled from C:anacondalibencodings\__init__.pyc
# C:anacondalibcodecs.pyc matches C:anacondalibcodecs.py
import codecs # precompiled from C:anacondalibcodecs.pyc
import _codecs # builtin
# C:anacondalibencodingsaliases.pyc matches C:anacondalibencodingsaliases.py
import encodings.aliases # precompiled from C:anacondalibencodingsaliases.pyc
import operator # builtin
# C:anacondalibfunctools.pyc matches C:anacondalibfunctools.py
import functools # precompiled from C:anacondalibfunctools.pyc
import _functools # builtin
import _locale # builtin
# C:anacondalibencodingscp1252.pyc matches C:anacondalibencodingscp1252.py
import encodings.cp1252 # precompiled from C:anacondalibencodingscp1252.pyc
# zipimport: found 13 names in C:anacondalibsite-packages
unipy-0.1.0-py2.7.egg
# zipimport: found 144 names in C:anacondalibsite-packagessetuptools-3.6-py2.7.egg
Python 2.7.7 |Anaconda 2.0.1 (64-bit)| (default, Jun 11 2014, 10:40:02) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and htt
我遇到的另一個(可能相關的)問題是每次關閉/打開 cygwin 時都需要重置路徑.我在 .bashrc 和 .profile 中輸入了以下文本,以嘗試永久設置路徑:
Another (possibly related) issue I'm having is needing to reset the path every time I close/open cygwin. I've entered the following text into .bashrc and .profile to try and set the path permanently:
# Set path to python from anaconda install
export PATH=/cygdrive/c/anaconda:$PATH
打開和關閉cygwin后,返回:
After opening and closing cygwin, I return to:
$ which python
/usr/bin/python
這可能與設置某些系統環境變量有關嗎?
Could this be related to setting certain system environment variables?
推薦答案
為了在 Cygwin 中使用交互式 Python shell,我使用了 -i 選項.
To work with the interactive Python shell in Cygwin I use the -i option.
為了從 Anaconda 安裝中獲取它,我使用了上面建議的步驟:
To get it from the Anaconda install, I used the steps suggested above:
$ export PATH=/cygdrive/c/anaconda:$PATH
$ which python
/cygdrive/c/anaconda/python
然后我在 Cygwin 中使用 -i 選項啟動 python:
Then I launch python within Cygwin with the -i option:
$ python -i
Python 2.7.8 |Anaconda 2.1.0 (64-bit)| (default, Jul 2 2014, 15:12:11) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>>>
這些庫也運行良好.例如,現在可以導入 pandas 庫(已通過 Anaconda 安裝).
The libraries are also working fine. For instance the pandas library (which has been installed through Anaconda) can be imported now.
>>>> import pandas
>>>> pandas.DataFrame
<class 'pandas.core.frame.DataFrame'>
現在為了永久保存,我在我的 bashrc 文件中添加了路徑:
Now to make this permanent I added the path in my bashrc file:
$ echo 'export PATH=/cygdrive/c/anaconda:$PATH' >> .bashrc
$ source .bashrc
$ which python
/cygdrive/c/anaconda/python
我希望這會有所幫助.
這篇關于在 Cygwin 中為 Anaconda 永久設置 Python 路徑的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!