Question

I am on Mac OS X 10.8.3 (Mountain Lion) and am trying to run a script in PyCharm. Python 2.7.2 is installed, I have installed Canopy and Gensim. I just do not understand what could be causing the error that I'm getting.

scipy.__version__ 

shows that v 0.11 is installed.

Here is the entirety of my output following a run of the script:

/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python "/util/LSA/Base LSA.py"

Traceback (most recent call last):

File "/util/LSA/Base LSA.py", line 8, in <module>
    from gensim import corpora, models, similarities, matutils
File "/Library/Python/2.7/site-packages/gensim-0.8.6-py2.7.egg/gensim/__init__.py", line 7, in <module>
    import utils, matutils, interfaces, corpora, models, similarities
File "/Library/Python/2.7/site-packages/gensim-0.8.6-py2.7.egg/gensim/matutils.py", line 20, in <module>
    import scipy.sparse
ImportError: No module named scipy.sparse

Process finished with exit code 1
Was it helpful?

Solution

I'd suggest using the Python.org version of Python, not the one that came with OSX, as there are some issues that are most easily overcome by installing the latest version - 2.7.4 in the case of the 2.x branch. Don't worry about breaking anything, both versions will happily coexist together. Once you have that, you can install the latest NumPy and SciPy binaries (get the 10.6 dmg files). NumPy is required for SciPy to work.

Make sure you set up PyCharm to work with the new version of Python, and double-check that your modules are installed in the right site-packages directory (it should be /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/). You can always copy all of the files in your /Library/Python/2.7/site-packages/ directory to the one I just mentioned, as the major.minor version of Python (2.7) is still the same. Then, you should be good to go. You will likely want to symlink /usr/local/bin/python to /Library/Frameworks/Python.framework/Versions/2.7/bin/python (it may be already) to make an easier shebang line, and don't forget to put /usr/local/bin in front of /usr/bin in your PATH for when you do command-line work, and for #!/usr/bin/env python shebangs. Good luck!

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