Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permanently set Python path for Anaconda within Cygwin

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?

like image 355
thomastodon Avatar asked Jun 17 '14 03:06

thomastodon


People also ask

How do I set the default Anaconda path?

Go to Start and search for "Anaconda Prompt" - right click this and choose "Open File Location", which will open a folder of shortcuts. Right click the "Anaconda Prompt" shortcut, choose "Properties" and you can adjust the starting dir in the "Start in" box.

How do I change my python to Anaconda by default?

Scroll down until you find Path, select it, and click edit. In the screen that appears, update the path that is pointing to your original python.exe to the one that is in the anaconda path. Close any open command window for update to take effect. Thanks.


1 Answers

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.

like image 108
SchizoBean Avatar answered Oct 02 '22 14:10

SchizoBean