Question

I want to use xlrd, xlwt, xlutils with sagemath. I have installed them in my system's Python(2.7.3) but sage environment is not recognizing them. Getting following error when I try to import with sage

ImportError: No module named xlrd`

But without sage its working fine. Any idea how can I make them work inside sage?? I am using Ubuntu 12(quantal),32 bits and Sage Version 5.8 with Python 2.7.5(sage's Python).

Faced same problem with Tkinter too but solved it using sudo apt-get install tk8.5-dev got solution form http://www.sagemath.org/doc/faq/faq-usage.html#how-to-get-sage-s-python-to-recognize-my-system-s-tcl-tk-install

But what for other libraries?

I tried to install them manually inside /usr/lib/sagemath/local/lib/python2.7/site-packages/ folder by putting tar files then extract them and then sudo python setup.py install but still not working.

Was it helpful?

Solution 2

Sage does not use the python installed in your system. It uses its own copy of python so while working with sage programs you would have to run the programs from terminal using this command

$ sage --python <Python_File>

Similarly sage does not uses the modules installed in the system's python. The Modules need to be installed under sage libraries. You have downloaded and extracted the folder right but used a wrong command. Now go again in the xlrd extracted folder and use this command.

$ sage --python setup.py install 

Now Everything should work.

Cheers

OTHER TIPS

Rather than installing them with the system Python, install them with Sage's Python: you can either do sage --sh: this starts a subshell with various environment variables set appropriately for use with Sage, in particular $PATH will have $SAGE_ROOT/local/bin first. Then install the packages with python setup.py install etc. Or you can just run Sage's Python directly with sage --python setup.py install ....

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top