在 Cygwin 中为 Anaconda 永久设置 Python 路径

Permanently set Python path for Anaconda within Cygwin(在 Cygwin 中为 Anaconda 永久设置 Python 路径)
本文介绍了在 Cygwin 中为 Anaconda 永久设置 Python 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试在我的 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 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

python arbitrarily incrementing an iterator inside a loop(python在循环内任意递增迭代器)
Joining a set of ordered-integer yielding Python iterators(加入一组产生 Python 迭代器的有序整数)
Iterating over dictionary items(), values(), keys() in Python 3(在 Python 3 中迭代字典 items()、values()、keys())
What is the Perl version of a Python iterator?(Python 迭代器的 Perl 版本是什么?)
How to create a generator/iterator with the Python C API?(如何使用 Python C API 创建生成器/迭代器?)
Python generator behaviour(Python 生成器行为)