python – Binarynomad https://binarynomad.com/blog Practicing contextual relativity for over 30 years... Mon, 22 Nov 2010 10:46:46 +0000 en-US hourly 1 https://wordpress.org/?v=4.8.25 Really? Is it that hard…. https://binarynomad.com/blog/2009/04/11/really-is-it-that-hard https://binarynomad.com/blog/2009/04/11/really-is-it-that-hard#respond Sat, 11 Apr 2009 23:47:04 +0000 http://binarynomad.com/blog/?p=432 I recently purchased the book (Beginning Python Visualization) because of my interest in Data Visualization and the want to learn Python. It is a great book, and I’m having a lot of fun going through it, but one of the first walls that hit me while walking through the excersices was the need to import modules to extend my programs.

Now importing a module (or code) is a pretty standard/common practice, it allows you to reuse existing programming snippits without having to write everything from scratch. A good example is the pySerial module. This provides functions to read data from a COM port. So all I have to do is import pySerial and I’m good to go. Except if your OS (like Mac Leopard) didn’t include it in the system modules, then you have to go out and manually install it yourself. I really wanted a simple installer like CPAN for PERL, and barring that, I was really hoping for a simple (single) file to download and drop into a directory, I tried searches like:

  • python modules install
  • python cpan
  • python mac modules

Over all the problems were:

  • There were custom installers for the module, or you had to compile/install by hand
  • You could install via Darwin Ports, but that had dependancies for Python 2.4 (I’m running 2.5) and I didn’t want to install a complete second (older) version of Python on my system.
  • There was no clear documentation on how to add a library of modules for your personal development.

Python’s own site quotes another wiki that says things like:

Python doesn’t have a CPAN.

Python comes with “Batteries Included”. The standard modules shipped with Python has a lot of good stuff, and for many common tasks you just don’t need the extra step of CPAN. Python’s standard library of modules is nothing to sneeze at!

I think Python shouldn’t have a CPAN. Basically, I think CPAN is too centralized a mechanism for finding modules, and the work to create a CPAN for Python could be better spent elsewhere.

…this isn’t very helpful if you aren’t a heavy coder and just need some unique functionality for your project, and you know that someone else has already built it.

Thankfully I came across easy_install, which seems like CPAN-lite for python. I was easily able to run easy_install pyserial and the correct module was found/downloaded/installed onto my system. No fuss, no mess.

I really think Apple and Python should make this more prominent on their sites.

]]>
https://binarynomad.com/blog/2009/04/11/really-is-it-that-hard/feed 0