OK, let's start to use Python! Well, first of all, where can I obtain it? It's a freeware, so don't need to ask for money to buy a licence, that's a first very good point!
I'm working with mainly 2 OS: Linux (very old Fedora) and OSX from Mac. It's easier for me to work now with the Mac on this project, but from what I understood, anything will be translated from one OS to the other one without problems. I also have a very uptodate Ubuntu in a VirtualBox, where I can also try things.
Python is already installed on the Mac. Fine! But it seems I will have to install "modules" (the way Python people call libraries). Me first problem is that other programs in my Mac depends on Python, so what If I do something wrong? To avoid this, I decided to install another Python distribution in the Port environment, and no to touch the /Library one.
Very easy to install, just a "sudo port install python-26" and it's OK!
I realized that a previous Python was already present, the 24. I install python_select and use it to define the default version to be 26, namely the 2.6.6 one.
Ok, ready to go.
First command:
Python 2.6.6 (r266:84292, Sep 9 2010, 10:10:29)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 5+7
12
So cool!
I quickly Google some informations and install some modules that seems to be of big interest:
scipy, numpy, pylab. All available by the "sudo port install" command.
The 2 other ones I installed today are numdisplay and pyfits, both are not in the port distribution. Easy to find the page where they can be downloaded, and after a gunzip-tar, I'm with directories in which it seems the tradition wants a "sudo python setup.py install" to do the job.
As I'm coming from IDL, I don't want to loose one of the 3 main issues of this language: the I (which stay for Interactive). I already know that Python can deal with the D (data) and the L (language), but for the I, it seems that the use of ipython is preferable. OK, not a problem, it's available from the port repository.
Now I can start to play with my brand new game!...
Here is a list of all the modules accessible from my ipython, using help ('modules'):
{CM:cmmacbook-2 ~/Python/Modules} ipython-2.6
Python 2.6.6 (r266:84292, Sep 9 2010, 10:10:29)
Type "copyright", "credits" or "license" for more information.
IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: help ('modules')
Please wait a moment while I gather a list of all available modules...
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/numerix/__init__.py:18: DeprecationWarning:
**********************************************************
matplotlib.numerix and all its subpackages are deprecated.
They will be removed soon. Please use numpy instead.
**********************************************************
warnings.warn(msg, DeprecationWarning)
AppKit _multibytecodec hotshot posix
Audio_mac _multiprocessing htmlentitydefs posixfile
BaseHTTPServer _random htmllib posixpath
Bastion _scproxy httplib pprint
CGIHTTPServer _socket ibrowse profile
Canvas _sqlite3 ic pspersistence
Carbon _sre icglue pstats
Cocoa _ssl icopen pty
CodeWarrior _strptime idlelib pwd
ColorPicker _struct igrid py2app
ConfigParser _symtable ihooks py_compile
Cookie _testcapi imaplib pyclbr
CoreFoundation _threading_local imghdr pydoc
Dialog _tkinter imp pydoc_topics
DocXMLRPCServer _warnings imputil pyexpat
EasyDialogs _weakref inspect pyfits
Explorer abc io pylab
FileDialog aepack ipipe pytz
Finder aetools ipy_app_completers quopri
FixTk aetypes ipy_autoreload random
Foundation aifc ipy_bzr re
FrameWork altgraph ipy_completers readline
HTMLParser anydbm ipy_constants repr
IN applesingle ipy_defaults resource
IPython appletrawmain ipy_editors rexec
InterpreterExec appletrunner ipy_exportdb rfc822
InterpreterPasteInput argvemulator ipy_extutil rlcompleter
MacOS array ipy_fsops robotparser
MimeWriter ast ipy_gnuglobal runpy
MiniAEFrame astyle ipy_greedycompleter sched
Nav asynchat ipy_jot scipy
Netscape asyncore ipy_kitcfg scitedirector
OSATerminology atexit ipy_legacy select
PhysicalQInput audiodev ipy_lookfor sets
PhysicalQInteractive audioop ipy_p4 setuptools
PixMapWrapper autoGIL ipy_pretty sgmllib
Queue base64 ipy_profile_doctest sha
Scientific bdb ipy_profile_none shelve
Scientific_affinitypropagation bdist_mpkg ipy_profile_numpy shlex
Scientific_interpolation bgenlocations ipy_profile_scipy shutil
Scientific_netcdf binascii ipy_profile_sh signal
Scientific_numerics_package_id binhex ipy_profile_zope site
Scientific_vector bisect ipy_pydb smtpd
ScrolledText bsddb ipy_rehashdir smtplib
SimpleDialog buildtools ipy_render sndhdr
SimpleHTTPServer bundlebuilder ipy_server socket
SimpleXMLRPCServer bz2 ipy_signals sqlite3
SocketServer cPickle ipy_stock_completers sre
StdSuites cProfile ipy_synchronize_with sre_compile
StringIO cStringIO ipy_system_conf sre_constants
SystemEvents calendar ipy_traits_completer sre_parse
Terminal cfmfile ipy_user_conf ssl
Tix cgi ipy_vimserver stat
Tkconstants cgitb ipy_which statvfs
Tkdnd chunk ipy_winpdb string
Tkinter clearcmd ipy_workdir stringold
UserDict cmath itertools stringprep
UserList cmd jobctrl strop
UserString code json struct
_AE codecs keyword subprocess
_AH codeop ledit sunau
_App collections lib2to3 sunaudio
_CF colorsys libxml2 symbol
_CG commands libxml2mod symtable
_CarbonEvt compileall linecache sys
_Cm compiler locale syslog
_Ctl configobj logging tabnanny
_Dlg contextlib macerrors tarfile
_Drag cookielib macholib telnetlib
_Evt copy macostools tempfile
_File copy_reg macpath terminalcommand
_Fm crypt macresource termios
_Folder csv macurl2path test
_Help ctypes mailbox textwrap
_IBCarbon curses mailcap this
_Icn datetime markupbase thread
_LWPCookieJar dateutil marshal threading
_Launch dbhash math time
_List dbm matplotlib timeit
_Menu decimal md5 tkColorChooser
_Mlte difflib mhlib tkCommonDialog
_MozillaCookieJar dircache mimetools tkFileDialog
_OSA dis mimetypes tkFont
_Qd distutils mimify tkMessageBox
_Qdoffs doctest mmap tkSimpleDialog
_Qt drv_libxml2 modulefinder toaiff
_Res dumbdbm modulegraph token
_Scrap dummy_thread mpl_toolkits tokenize
_Snd dummy_threading multifile trace
_TE easy_install multiprocessing traceback
_Win email mutex tty
__builtin__ encodings netrc turtle
__future__ envpersist new types
_abcoll errno nis unicodedata
_ast exceptions nntplib unittest
_bisect ext_rescapture nose urllib
_bsddb fcntl ntpath urllib2
_builtinSuites filecmp nturl2path urlparse
_bytesio fileinput numbers user
_codecs findertools numdisplay uu
_codecs_cn fnmatch numeric_formats uuid
_codecs_hk formatter numpy validate
_codecs_iso2022 fpformat objc videoreader
_codecs_jp fractions opcode warnings
_codecs_kr ftplib operator wave
_codecs_tw functools optparse weakref
_collections future_builtins os webbrowser
_csv gc os2emxpath whichdb
_ctypes gdbm parser win32clip
_ctypes_test genericpath pdb wsgiref
_curses gensuitemodule pickle xdrlib
_curses_panel gestalt pickleshare xml
_elementtree getopt pickletools xml2po
_fileio getpass pimp xmllib
_functools gettext pipes xmlrpclib
_hashlib glob pkg_resources xxsubtype
_heapq grp pkgutil zipfile
_hotshot gzip platform zipimport
_json hashlib plistlib zlib
_locale heapq popen2
_lsprof hmac poplib
Enter any module name to get more help. Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".
Well, it's lot!
I will first concentrate on trying to reproduce what I'm teaching to the students in IDL. The best could be for example to try to follow the Cook-book I wrote 10 years ago: http://132.248.1.102/~morisset/idl_cours/IDL/index_local.htm
Aucun commentaire:
Enregistrer un commentaire