在Cygwin中永久设置Anaconda的Python路径 [英] Permanently set Python path for Anaconda within Cygwin
问题描述
我想在我的Windows 7机器上安装Anaconda。我经常使用cygwin来做我的命令行工作,我想从那里管理Anaconda。我已经通过图形安装程序没有任何问题,并检查必要的框,重置我的默认路径这个安装的python。我去检查python是在哪里,最初我得到这个...
$ which python
/ usr / bin / python
从这里python工作正常...
$ python
Python 2.7.5(默认,2013年10月2日,22:34:09)
[GCC 4.8.1] on cygwin
键入帮助,版权,信用或许可证了解更多信息。
但我想从anaconda工作,所以我只需要重新定义我的路径。 。
$ export PATH = / cygdrive / c / anaconda:$ PATH
$ which python
/ cygdrive / c / anaconda / python
现在我应该好了,进入python,它只是挂起
$ python
任何想法为什么会发生这种情况? verbose return,below ...
$ python -v
安装zipimport hook
import zipimport#内置
#安装zipimport hook
#C:\anaconda\lib\site.pyc与C:\anaconda\lib\site.py
import site#precompiled from C:\anaconda\lib\site.pyc
#C:\anaconda\lib\os.pyc matches C:\anaconda\lib\os.py
import os#precompiled from C:\anaconda\lib\os.pyc
import errno#builtin
import nt#builtin
#C:\anaconda\lib\\\
tpath。 pyc匹配C:\anaconda\lib\\\
tpath.py
import ntpath#从C:\anaconda\lib\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\path \stat.pyc匹配C:\anaconda\lib\stat.py
import stat#从C:\anaconda\lib\stat.pyc预编译
#C:\ anaconda\lib\genericpath.pyc匹配C:\anaconda\lib\genericpath.py
import genericpath#从C:\anaconda\lib\genericpath.pyc预编译
# C:\anaconda\lib\warnings.pyc与C:\anaconda\lib\warnings.py
匹配import warnings#precompiled from C:\anaconda\lib\warnings.pyc
#C:\anaconda\lib\linecache.pyc与C:\anaconda\lib\linecache.py
匹配import linecache#precompiled from C:\anaconda\lib\ linecache.pyc
#C:\anaconda\lib\types.pyc匹配C:\anaconda\lib\types.py
导入类型#从C:\anaconda\\预编译\\ lib \types.pyc
#C:\anaconda\lib\UserDict.pyc匹配C:\anaconda\lib\UserDict.py
import UserDict#从C: \anaconda\lib\UserDict.pyc
#C:\anaconda\lib\_abcoll.pyc匹配C:\anaconda\lib\_abcoll.py
import _abcoll#预编译自C:\anaconda\lib\_abcoll.pyc
#C:\anaconda\lib\abc.pyc matches C:\anaconda\lib\abc.py
import abc#从C:\anaconda\lib\abc.pyc中预编译
#C:\anaconda\lib\_weakrefset.pyc与C:\anaconda\lib\_weakrefset匹配。 py
import _weakrefset#precompiled from C:\anaconda\lib\weakrefset.pyc
import _weakref#builtin
#C:\anaconda\lib\copy_reg.pyc matches C:\anaconda\lib\copy_reg.py
import copy_reg#从C:\anaconda\lib\copy_reg.pyc预编译
#C:\anaconda\lib\ traceback.pyc匹配C:\anaconda\lib\traceback.py
import traceback#precompiled from C:\anaconda\lib\traceback.pyc
#C:\anaconda\\ \\ lib \sysconfig.pyc匹配C:\anaconda\lib\sysconfig.py
import sysconfig#precompiled from C:\anaconda\lib\sysconfig.pyc
#C: \anaconda\lib\re.pyc matches C:\anaconda\lib\re.py
import re#从C:\anaconda\lib\re.pyc预编译
#C:\anaconda\lib\sre_compile.pyc匹配C:\anaconda\lib\sre_compile.py
import sre_compile#从C:\anaconda\lib\sre_compile编译预编译。 pyc
import _sre#builtin
#C:\anaconda\lib\sre_parse.pyc matches C:\anaconda\lib\sre_parse.py
import sre_parse#precompiled from C:\anaconda\lib\sre_parse.pyc
#C:\anaconda\lib\sre_constants.pyc matches C:\anaconda\lib\sre_constants.py
import sre_constants#precompiled from C:\anaconda\lib\sre_constants.pyc
#C:\anaconda\lib\locale.pyc matches C:\anaconda\lib\locale.py
import locale#从C:\anaconda\lib\locale.pyc中编译
import encodings#目录C:\anaconda\lib\encodings
#C:\anaconda \lib \encodings\__init __。pyc matches C:\anaconda\lib\encodings\__init __。py
import encodings#precompiled from C:\anaconda\lib\encodings\ __init __。pyc
#C:\anaconda\lib\codecs.pyc matches C:\anaconda\lib\codecs.py
import codecs#precompiled from C:\anaconda\\ \\ lib \codecs.pyc
import _codecs#builtin
#C:\anaconda\lib\encodings\aliases.pyc匹配C:\anaconda\lib\encodings\ aliases.py
import encodings.aliases#precompiled from C:\anaconda\lib\encodings\aliases.pyc
import operator#builtin
#C:\anaconda\ lib \functools.pyc匹配C:\anaconda\lib\functools.py
import functools#从C:\anaconda\lib\functools.pyc预编译
import _functools#builtin
import _locale#builtin
#C:\anaconda\lib\encodings\cp1252.pyc与C:\anaconda\lib\encodings\cp1252.py
匹配import encodings.cp1252#从C:\anaconda\lib\encodings\cp1252.pyc预编译
#zipimport:在C:\anaconda\lib\site-packages\runipy中找到13个名称-0.1.0-py2.7.egg
#zipimport:在C:\anaconda\lib\site-packages\setuptools-3.6-py2.7.egg
中找到144个名称Python 2.7.7 | Anaconda 2.0.1(64位)| (默认,2014年6月11日,10:40:02)[MSC v.1500 64位(AMD64)] on win32
更多信息,请输入帮助,版权,信用或
Anaconda由Continuum Analytics为您提供。
请检查:http://continuum.io/thanks和htt
可能相关)问题我有需要重置路径每次我关闭/打开cygwin。我输入以下文本到.bashrc和.profile尝试并永久设置路径:
#设置路径到python从anaconda安装
export PATH = / cygdrive / c / anaconda:$ PATH
并关闭cygwin,我回到:
$ which python
/ usr / bin / python
这可能与设置某些系统环境变量有关吗?
解决方案要使用Cygwin中的交互式Python shell,我使用-i选项。
要从Anaconda安装,使用上面建议的步骤:
$ export PATH = / cygdrive / c / anaconda:$ PATH
$ which python
/ cygdrive / c / anaconda / python
然后我在Cygwin中启动python - i选项:
$ python -i
Python 2.7.8 | Anaconda 2.1.0(64位)| (默认,2014年7月2日,15:12:11)[MSC v.1500 64位(AMD64)] on win32
更多信息,请输入帮助,版权,信用或
Anaconda由Continuum Analytics为您提供。
请检查:http://continuum.io/thanks和https://binstar.org
>>>>
库也工作正常。例如,现在可以导入pandas库(已通过Anaconda安装)。
>>> import pandas
>>>>> pandas.DataFrame
< class'pandas.core.frame.DataFrame'>
现在为了使这个永久性,我在我的bashrc文件中添加了路径:
$ echo'export PATH = / cygdrive / c / anaconda:$ PATH'>> .bashrc
$ source .bashrc
$ which python
/ cygdrive / c / anaconda / 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
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.
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
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:\anaconda\lib\site.pyc matches C:\anaconda\lib\site.py import site # precompiled from C:\anaconda\lib\site.pyc # C:\anaconda\lib\os.pyc matches C:\anaconda\lib\os.py import os # precompiled from C:\anaconda\lib\os.pyc import errno # builtin import nt # builtin # C:\anaconda\lib\ntpath.pyc matches C:\anaconda\lib\ntpath.py import ntpath # precompiled from C:\anaconda\lib\ntpath.pyc # C:\anaconda\lib\stat.pyc matches C:\anaconda\lib\stat.py import stat # precompiled from C:\anaconda\lib\stat.pyc # C:\anaconda\lib\genericpath.pyc matches C:\anaconda\lib\genericpath.py import genericpath # precompiled from C:\anaconda\lib\genericpath.pyc # C:\anaconda\lib\warnings.pyc matches C:\anaconda\lib\warnings.py import warnings # precompiled from C:\anaconda\lib\warnings.pyc # C:\anaconda\lib\linecache.pyc matches C:\anaconda\lib\linecache.py import linecache # precompiled from C:\anaconda\lib\linecache.pyc # C:\anaconda\lib\types.pyc matches C:\anaconda\lib\types.py import types # precompiled from C:\anaconda\lib\types.pyc # C:\anaconda\lib\UserDict.pyc matches C:\anaconda\lib\UserDict.py import UserDict # precompiled from C:\anaconda\lib\UserDict.pyc # C:\anaconda\lib\_abcoll.pyc matches C:\anaconda\lib\_abcoll.py import _abcoll # precompiled from C:\anaconda\lib\_abcoll.pyc # C:\anaconda\lib\abc.pyc matches C:\anaconda\lib\abc.py import abc # precompiled from C:\anaconda\lib\abc.pyc # C:\anaconda\lib\_weakrefset.pyc matches C:\anaconda\lib\_weakrefset.py import _weakrefset # precompiled from C:\anaconda\lib\_weakrefset.pyc import _weakref # builtin # C:\anaconda\lib\copy_reg.pyc matches C:\anaconda\lib\copy_reg.py import copy_reg # precompiled from C:\anaconda\lib\copy_reg.pyc # C:\anaconda\lib\traceback.pyc matches C:\anaconda\lib\traceback.py import traceback # precompiled from C:\anaconda\lib\traceback.pyc # C:\anaconda\lib\sysconfig.pyc matches C:\anaconda\lib\sysconfig.py import sysconfig # precompiled from C:\anaconda\lib\sysconfig.pyc # C:\anaconda\lib\re.pyc matches C:\anaconda\lib\re.py import re # precompiled from C:\anaconda\lib\re.pyc # C:\anaconda\lib\sre_compile.pyc matches C:\anaconda\lib\sre_compile.py import sre_compile # precompiled from C:\anaconda\lib\sre_compile.pyc import _sre # builtin # C:\anaconda\lib\sre_parse.pyc matches C:\anaconda\lib\sre_parse.py import sre_parse # precompiled from C:\anaconda\lib\sre_parse.pyc # C:\anaconda\lib\sre_constants.pyc matches C:\anaconda\lib\sre_constants.py import sre_constants # precompiled from C:\anaconda\lib\sre_constants.pyc # C:\anaconda\lib\locale.pyc matches C:\anaconda\lib\locale.py import locale # precompiled from C:\anaconda\lib\locale.pyc import encodings # directory C:\anaconda\lib\encodings # C:\anaconda\lib\encodings\__init__.pyc matches C:\anaconda\lib\encodings\__init__.py import encodings # precompiled from C:\anaconda\lib\encodings\__init__.pyc # C:\anaconda\lib\codecs.pyc matches C:\anaconda\lib\codecs.py import codecs # precompiled from C:\anaconda\lib\codecs.pyc import _codecs # builtin # C:\anaconda\lib\encodings\aliases.pyc matches C:\anaconda\lib\encodings\aliases.py import encodings.aliases # precompiled from C:\anaconda\lib\encodings\aliases.pyc import operator # builtin # C:\anaconda\lib\functools.pyc matches C:\anaconda\lib\functools.py import functools # precompiled from C:\anaconda\lib\functools.pyc import _functools # builtin import _locale # builtin # C:\anaconda\lib\encodings\cp1252.pyc matches C:\anaconda\lib\encodings\cp1252.py import encodings.cp1252 # precompiled from C:\anaconda\lib\encodings\cp1252.pyc # zipimport: found 13 names in C:\anaconda\lib\site-packages\runipy-0.1.0-py2.7.egg # zipimport: found 144 names in C:\anaconda\lib\site-packages\setuptools-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
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
After opening and closing cygwin, I return to:
$ which python /usr/bin/python
Could this be related to setting certain system environment variables?
解决方案To work with the interactive Python shell in Cygwin I use the -i option.
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
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 >>>>
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'>
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
I hope this helps.
这篇关于在Cygwin中永久设置Anaconda的Python路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!