2014年2月1日土曜日

Pythonを始めた。

matlabは高価で高機能なためそのぶんパソコンのスペースもたくさんとられる。例えば自分のmacbookairに入っていたmatlab 2011はソフトウェアだけで>5GB。

ということでストレージスペースの少ないmacbookairには不向き。

FABMのデベロッパーたちはpythonを推しているらしいので自分もpythonへ移行することに。

以前ブログで話したがmacbookairのターミナル上でpythonを起動してimport PyQt4とするとHomeBrewやMacPortsで二度に渡りPyQt4とPySideをインストールしたにも関わらずエラー文が出てうまくいかなかったがこの原因がわかった。

自分のmacbookairには数種類のpythonがインストールされていた。ターミナルでpythonと売った後にtabを二度打つと:

$ python

python            python2.5-config  python2.7         pythonw2.5
python-config     python2.6         python2.7-config  pythonw2.6
python2.5         python2.6-config  pythonw           pythonw2.7

こんな感じで何種類ものpythonがインストールされてしまっているよう。

そしてもしかしたらPyQt4やPySideといったモジュールはディフォルトのpythonじゃなくて他のバージョンにインストールされているのではないかと考えそれぞれのpythonをターミナルで起動してhelp()→modulesの手順(参照:https://groups.google.com/d/msg/comp.lang.python/TQfB9720m5Q/KIUUrG9wFBsJ)で確認してみるとpython2.7にPyQt4が入っていることがわかった:

$ python2.7
Python 2.7.6 (default, Nov 18 2013, 15:12:51) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> modules

Please wait a moment while I gather a list of all available modules...


** (process:1406): WARNING **: Trying to register gtype 'GMountMountFlags' as enum when in fact it is of type 'GFlags'

** (process:1406): WARNING **: Trying to register gtype 'GDriveStartFlags' as enum when in fact it is of type 'GFlags'

** (process:1406): WARNING **: Trying to register gtype 'GSocketMsgFlags' as enum when in fact it is of type 'GFlags'
Audio_mac           _lsprof             ftplib              pyexpat
BaseHTTPServer      _markerlib          functools           pygtk
Bastion             _multibytecodec     future_builtins     quopri
CGIHTTPServer       _multiprocessing    gc                  random
Canvas              _osx_support        genericpath         re
Carbon              _pyio               gensuitemodule      readline
CodeWarrior         _random             gestalt             repr
ColorPicker         _scproxy            getopt              resource
ConfigParser        _socket             getpass             rexec
Cookie              _sqlite3            gettext             rfc822
Dialog              _sre                gio                 rlcompleter
DocXMLRPCServer     _ssl                glib                robotparser
EasyDialogs         _strptime           glob                runpy
Explorer            _struct             gobject             sched
FileDialog          _symtable           gps                 select
Finder              _sysconfigdata      grp                 sets
FixTk               _testcapi           gzip                setuptools
FrameWork           _threading_local    hashlib             sgmllib
HTMLParser          _warnings           heapq               sha
IN                  _weakref            hmac                shelve
MacOS               _weakrefset         hotshot             shlex
MimeWriter          abc                 htmlentitydefs      shutil
MiniAEFrame         aepack              htmllib             signal
Nav                 aetools             httplib             sip
Netscape            aetypes             ic                  sipconfig
OSATerminology      aifc                icglue              sipdistutils
PixMapWrapper       antigravity         icopen              site
PyQt4               anydbm              idlelib             smtpd
Queue               applesingle         ihooks              smtplib
ScrolledText        appletrawmain       imaplib             sndhdr
SimpleDialog        appletrunner        imghdr              socket
SimpleHTTPServer    argparse            imp                 sqlite3
SimpleXMLRPCServer  argvemulator        importlib           sre
SocketServer        array               imputil             sre_compile
StdSuites           ast                 inspect             sre_constants
StringIO            asynchat            io                  sre_parse
SystemEvents        asyncore            itertools           ssl
Terminal            atexit              json                stat
Tix                 audiodev            keyword             statvfs
Tkconstants         audioop             lib2to3             string
Tkdnd               autoGIL             libproxy            stringold
Tkinter             base64              libxml2             stringprep
UserDict            bdb                 libxml2mod          strop
UserList            bgenlocations       linecache           struct
UserString          binascii            locale              subprocess
_AE                 binhex              logging             sunau
_AH                 bisect              macerrors           sunaudio
_App                bsddb               macostools          symbol
_CF                 buildtools          macpath             symtable
_CG                 bundlebuilder       macresource         sys
_CarbonEvt          bz2                 macurl2path         sysconfig
_Cm                 cPickle             mailbox             syslog
_Ctl                cProfile            mailcap             tabnanny
_Dlg                cStringIO           markupbase          tarfile
_Drag               cairo               marshal             telnetlib
_Evt                calendar            math                tempfile
_File               cfmfile             md5                 terminalcommand
_Fm                 cgi                 mhlib               termios
_Folder             cgitb               mimetools           test
_Help               chunk               mimetypes           textwrap
_IBCarbon           cmath               mimify              this
_Icn                cmd                 mmap                thread
_LWPCookieJar       code                modulefinder        threading
_Launch             codecs              multifile           time
_List               codeop              multiprocessing     timeit
_Menu               collections         mutex               tkColorChooser
_Mlte               colorsys            netCDF4             tkCommonDialog
_MozillaCookieJar   commands            netCDF4_utils       tkFileDialog
_OSA                compileall          netcdftime          tkFont
_Qd                 compiler            netrc               tkMessageBox
_Qdoffs             contextlib          new                 tkSimpleDialog
_Qt                 cookielib           nis                 toaiff
_Res                copy                nntplib             token
_Scrap              copy_reg            nose                tokenize
_Snd                crypt               ntpath              trace
_TE                 csv                 nturl2path          traceback
_Win                ctypes              numbers             ttk
__builtin__         curses              numpy               tty
__future__          datetime            opcode              turtle
_abcoll             dbhash              operator            types
_ast                dbm                 optparse            unicodedata
_bisect             dbus                os                  unittest
_bsddb              dbus_bindings       os2emxpath          urllib
_builtinSuites      decimal             parser              urllib2
_codecs             difflib             pdb                 urlparse
_codecs_cn          dircache            pickle              user
_codecs_hk          dis                 pickletools         uu
_codecs_iso2022     distutils           pimp                uuid
_codecs_jp          doctest             pipes               videoreader
_codecs_kr          drv_libxml2         pkg_resources       warnings
_codecs_tw          dsextras            pkgutil             wave
_collections        dumbdbm             platform            weakref
_csv                dummy_thread        plistlib            webbrowser
_ctypes             dummy_threading     popen2              whichdb
_ctypes_test        easy_install        poplib              wsgiref
_curses             email               posix               xdrlib
_curses_panel       encodings           posixfile           xml
_dbus_bindings      errno               posixpath           xml2po
_dbus_glib_bindings exceptions          pprint              xmllib
_elementtree        fcntl               profile             xmlrpclib
_functools          filecmp             pstats              xxsubtype
_hashlib            fileinput           pty                 zipfile
_heapq              findertools         pwd                 zipimport
_hotshot            fnmatch             py_compile          zlib
_io                 formatter           pyclbr              
_json               fpformat            pydoc               
_locale             fractions           pydoc_data          

Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose descriptions contain the word "spam".

よしこれでPyQt4そしてnetCDF4も使えるということがわかった。一件落着。

0 件のコメント:

コメントを投稿