1

I installed the scikits package but can't import it, I am on Macbook, please let me know what is missing here

bash-3.2$ sudo port install py26-scikits-learn
--->  Computing dependencies for py26-scikits-learn
--->  Fetching archive for py26-scikits-learn
--->  Attempting to fetch py26-scikits-learn-0.8_0.darwin_10.x86_64.tbz2 from http://packages.macports.org/py26-scikits-learn
--->  Fetching py26-scikits-learn
--->  Verifying checksum(s) for py26-scikits-learn
--->  Extracting py26-scikits-learn
--->  Configuring py26-scikits-learn
--->  Building py26-scikits-learn
--->  Staging py26-scikits-learn into destroot
--->  Installing py26-scikits-learn @0.8_0
--->  Activating py26-scikits-learn @0.8_0
--->  Cleaning py26-scikits-learn
bash-3.2$ python -c "import scikits.learn as skl; skl.test()"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named scikits.learn

FIXED How do I uninstall python from OSX Leopard so that I can use the MacPorts version?

Community
  • 1
  • 1
daydreamer
  • 87,243
  • 191
  • 450
  • 722
  • 1
    Don't forget that MacPorts uses its own version of Python, and installs against that. You'll need to run that Python, not the system one. – Daniel Roseman Aug 16 '11 at 20:33
  • where can I find the path of python in port? – daydreamer Aug 16 '11 at 20:40
  • http://stackoverflow.com/questions/118813/how-do-i-uninstall-python-from-osx-leopard-so-that-i-can-use-the-macports-version – daydreamer Aug 16 '11 at 21:00
  • 1
    Do not attempt to uninstall the Apple-supplied system Python in any version of OS X! It's part of OS X. Just change your SHELL path to put `/opt/local/bin` first on your path. Or use absolute paths. This has been answered many times on SO and elsewhere. – Ned Deily Aug 16 '11 at 23:35
  • Yeah! I did that and it worked just fine – daydreamer Aug 17 '11 at 01:29

1 Answers1

0

Unfortunately I don't know how port commnad works (I guess it comes from MacPorts) but you should use Python to maintain Python packages (which is encouraged eg. by homebrew). You can try pip:

sudo pip install scikits.learn

In OS X Lion default version of Python is 2.7, if you want to use 2.6 you have to:

sudo python2.6 pip install scikits.learn

(Python keeps separate packages for every version)

You can browse all packages available via pip (or easy_install) using pypi or search it with

pip searh foo

If you are afraid of cluttering you system please give a try virtualenvwrapper.

radious
  • 812
  • 6
  • 21
  • 1
    If you don't know how the `port` command works, then perhaps you shouldn't be making recommendations about not using it. There is nothing wrong with using a general package manager to maintain Python packages on OS X (like MacPorts or homebrew or Fink) just as there is nothing wrong with using a Linux distro package manager like `apt-get` to maintain them. – Ned Deily Aug 16 '11 at 23:36
  • Of course it's nothing wrong with maintaining Python packages with system package manager. The same goes for ports or any other OS X package manager. But it's not the best way. Installing Python packages via PM is a relict of an old times when Python didn't have way of package managing of its own. Nowadays choosing pip is much better. You can freely switch between Python versions, keep different clean environment (it's really important, believe me) and less bother with system updates (refreshing my all environments after updating to Lion was only reinstalling all packages). – radious Aug 17 '11 at 13:35
  • Actually, it's not a relic of old times. The power of using a more general package manager on OS X comes when the Python packages you are installing also depend on third-party libraries not supplied with OS X. MySQLdb is a prime example. Getting all of the pieces to be built compatibly is often non-trivial. `pip` is fine for installing packages not already packaged. The need for `virtualenv` is much less on OS X with Python framework builds which provide an effective isolation mechanism not available with traditional UNIX Python builds. Lots of options. – Ned Deily Aug 17 '11 at 16:38