Prev: defining, raising and catching exceptions
Next: Finding the version # of a module, and py moduleproblem
From: W. eWatson on 5 Aug 2010 20:55 It's been awhile since I've used python, and I recall there is a way to find the version number from the IDLE command line prompt. dir, help, __version.__? I made the most minimal change to a program, and it works for me, but not my partner. He gets Traceback (most recent call last): File "C:\Documents and Settings\HP_Administrator.DavesDesktop\Desktop\NC-FireballReport20100729.py", line 40, in <module> from scipy import stats as stats # scoreatpercentile File "C:\Python25\lib\site-packages\scipy\stats\__init__.py", line 7, in <module> from stats import * File "C:\Python25\lib\site-packages\scipy\stats\stats.py", line 191, in <module> import scipy.special as special File "C:\Python25\lib\site-packages\scipy\special\__init__.py", line 22, in <module> from numpy.testing import NumpyTest ImportError: cannot import name NumpyTest Here are the first few lines of code. import sys, os, glob import string from numpy import * from datetime import datetime, timedelta import time from scipy import stats as stats # scoreatpercentile I'm pretty sure he has the same version of Python, 2.5, but perhaps not the numpy or scipy modules. I need to find out his version numbers. -- Wayne Watson (Watson Adventures, Prop., Nevada City, CA) (121.015 Deg. W, 39.262 Deg. N) GMT-8 hr std. time) Obz Site: 39� 15' 7" N, 121� 2' 32" W, 2700 feet
From: MRAB on 5 Aug 2010 21:23 W. eWatson wrote: > It's been awhile since I've used python, and I recall there is a way to > find the version number from the IDLE command line prompt. dir, help, > __version.__? > > I made the most minimal change to a program, and it works for me, but > not my partner. He gets > > Traceback (most recent call last): > File "C:\Documents and > Settings\HP_Administrator.DavesDesktop\Desktop\NC-FireballReport20100729.py", > line 40, in <module> > from scipy import stats as stats # scoreatpercentile > File "C:\Python25\lib\site-packages\scipy\stats\__init__.py", line 7, > in <module> > from stats import * > File "C:\Python25\lib\site-packages\scipy\stats\stats.py", line 191, > in <module> > import scipy.special as special > File "C:\Python25\lib\site-packages\scipy\special\__init__.py", line > 22, in <module> > from numpy.testing import NumpyTest > ImportError: cannot import name NumpyTest > > Here are the first few lines of code. > > import sys, os, glob > import string > from numpy import * > from datetime import datetime, timedelta > import time > from scipy import stats as stats # scoreatpercentile > > I'm pretty sure he has the same version of Python, 2.5, but perhaps not > the numpy or scipy modules. I need to find out his version numbers. > Try: import numpy help(numpy.version) BTW, on Python 2.6 I can see that there's "numpytest" but not "NumpyTest".
From: W. eWatson on 5 Aug 2010 21:40 On 8/5/2010 6:13 PM, Steven D'Aprano wrote: > On Thu, 05 Aug 2010 17:55:30 -0700, W. eWatson wrote: > >> I'm pretty sure he has the same version of Python, 2.5, but perhaps not >> the numpy or scipy modules. I need to find out his version numbers. > > It's only a convention, but the usual way is to check the __version__ > attribute. It works for Numpy: > >>>> import numpy >>>> numpy.__version__ > '1.0.3' > > > It is now written in my Py book. Thanks.
From: W. eWatson on 5 Aug 2010 21:42 On 8/5/2010 6:23 PM, MRAB wrote: > W. eWatson wrote: >> It's been awhile since I've used python, and I recall there is a way >> to find the version number from the IDLE command line prompt. dir, >> help, __version.__? >> >> I made the most minimal change to a program, and it works for me, but >> not my partner. He gets >> >> Traceback (most recent call last): >> File "C:\Documents and >> Settings\HP_Administrator.DavesDesktop\Desktop\NC-FireballReport20100729.py", >> line 40, in <module> >> from scipy import stats as stats # scoreatpercentile >> File "C:\Python25\lib\site-packages\scipy\stats\__init__.py", line 7, >> in <module> >> from stats import * >> File "C:\Python25\lib\site-packages\scipy\stats\stats.py", line 191, >> in <module> >> import scipy.special as special >> File "C:\Python25\lib\site-packages\scipy\special\__init__.py", line >> 22, in <module> >> from numpy.testing import NumpyTest >> ImportError: cannot import name NumpyTest >> >> Here are the first few lines of code. >> >> import sys, os, glob >> import string >> from numpy import * >> from datetime import datetime, timedelta >> import time >> from scipy import stats as stats # scoreatpercentile >> >> I'm pretty sure he has the same version of Python, 2.5, but perhaps >> not the numpy or scipy modules. I need to find out his version numbers. >> > Try: > > import numpy > help(numpy.version) > > BTW, on Python 2.6 I can see that there's "numpytest" but not > "NumpyTest". I have to stick with 2.5 for comparability with my partner. He's non-Python but was able to get Python 2.5 working. I think he somehow bumped ahead to a later version of numpy than I have.
From: Philip Semanchuk on 5 Aug 2010 21:47 On Aug 5, 2010, at 8:55 PM, W. eWatson wrote: > It's been awhile since I've used python, and I recall there is a way > to find the version number from the IDLE command line prompt. dir, > help, __version.__? Hi Wayne, FYI it's got nothing to do with IDLE, it's just a question of whether or not the module in question exposes any kind of a version attribute. There's no standard, unfortunately. The most popular convention seems to be via an attribute called __version__, but I've also seen __VERSION__, VERSION, and version. Here's some code that I wrote that you might find useful. It's from a setup.py and it checks a list of modules on which our project depends to see if (a) they're installed and (b) if the version installed is adequate. In the snippet below, dependencies is a list of custom classes that represent modules we need (e.g. numpy). # Try each module for dependency in dependencies: try: __import__(dependency.name) except ImportError: # Uh oh! dependency.installed = None else: # The module loaded OK. Get a handle to it and try to extract # version info. # Many Python modules follow the convention of providing their # version as a string in a __version__ attribute. module = sys.modules[dependency.name] # This is what I default to. dependency.installed = "[version unknown]" for attribute_name in ("__version__", "__VERSION__", "VERSION", "version"): if hasattr(module, attribute_name): dependency.installed = getattr(module, attribute_name) break Hope this helps a little, Philip
|
Next
|
Last
Pages: 1 2 3 Prev: defining, raising and catching exceptions Next: Finding the version # of a module, and py moduleproblem |