Yup, the version module isn't auto-imported into the top level, so doing 'from fabric.version import get_version' is probably the "best" way to do this. As Todd showed, 'import fabric.version' and then referencing things in that module like get_version or __version__, would also work.
On Mon, Aug 26, 2013 at 7:47 AM, Todd DeLuca <[email protected]> wrote: > Or it could be that you are not importing the "fabric.version" module, just > the "fabric" package. > > > On Mon, Aug 26, 2013 at 10:23 AM, Todd DeLuca <[email protected]> wrote: >> >> This works for me: >> >> $ git clone https://github.com/fabric/fabric >> $ python -c 'import sys; sys.path.append("fabric"); import fabric.version; >> print fabric.version.__version__' >> 1.6.1 >> >> I'm not sure how you have your code laid out, but try appending >> "static/fabric" to sys.path instead of "static/fabric/fabric". >> >> Regards, >> Todd >> >> >> >> On Sun, Aug 25, 2013 at 3:17 PM, Andrew Latham <[email protected]> wrote: >>> >>> Jeff, sorry I made some assumptions. >>> >>> Here is what I am doing >>> >>> test.py >>> >>> #!/usr/bin/env python >>> >>> import sys >>> sys.path.append('static/pycrypto/lib/Crypto') >>> sys.path.append('static/paramiko/paramiko') >>> sys.path.append('static/fabric/fabric') >>> >>> import Crypto >>> import paramiko >>> import fabric >>> >>> print "Pycrypto Version: " + str(Crypto.version_info) >>> print "Paramiko Version: " + str(paramiko.__version__) >>> print "Fabric Version: "+ fabric.version >>> <<< EOF >>> >>> here is what I get >>> example >>> >>> python test.py >>> Pycrypto Version: (2, 6, 0, 'final', 0) >>> Paramiko Version: 1.9.0 >>> Traceback (most recent call last): >>> File "test.py", line 15, in <module> >>> print "Fabric Version: "+ fabric.version >>> AttributeError: 'module' object has no attribute 'version' >>> <<< EOF >>> >>> I have messed around and decided that it would be better to ask the >>> list. I was able to import the get_version() directly. >>> >>> >>> On Sun, Aug 25, 2013 at 3:02 PM, Jeff Forcier <[email protected]> >>> wrote: >>> > Not even an actual traceback, or the code that actually involves >>> > Fabric itself? Give us something to work with here :( >>> > >>> > On Sun, Aug 25, 2013 at 6:15 AM, Andrew Latham <[email protected]> >>> > wrote: >>> >> All.... >>> >> >>> >> I am attempting to load pycrypto, paramiko, and fabric from a local >>> >> directory called static. >>> >> >>> >> I have a project as follows >>> >> >>> >> project/project.py >>> >> project/static/pycrypto >>> >> project/static/paramiko >>> >> project/static/fabric >>> >> >>> >> #!/usr/bin/env python >>> >> import sys, re, logging >>> >> sys.path.append('static/pycrypto/lib/Crypto') >>> >> sys.path.append('static/paramiko/paramiko') >>> >> import Crypto >>> >> import paramiko >>> >> >>> >> I have pycrypto and paramiko importing correctly and printing their >>> >> version as a test. >>> >> >>> >> When I attempt to do the same with fabric it does not work. I can >>> >> specify a file or function to load and use it. Importing the api.py >>> >> fails. I doubt I am the first to hit this. >>> >> >>> >> >>> >> -- >>> >> ~ Andrew "lathama" Latham [email protected] http://lathama.net ~ >>> >> >>> >> _______________________________________________ >>> >> Fab-user mailing list >>> >> [email protected] >>> >> https://lists.nongnu.org/mailman/listinfo/fab-user >>> > >>> > >>> > >>> > -- >>> > Jeff Forcier >>> > Unix sysadmin; Python/Ruby engineer >>> > http://bitprophet.org >>> >>> >>> >>> -- >>> ~ Andrew "lathama" Latham [email protected] http://lathama.net ~ >>> >>> _______________________________________________ >>> Fab-user mailing list >>> [email protected] >>> https://lists.nongnu.org/mailman/listinfo/fab-user >> >> >> >> >> -- >> Todd DeLuca >> Scientific Programmer >> http://todddeluca.com >> > > > > -- > Todd DeLuca > Scientific Programmer > http://todddeluca.com > > > _______________________________________________ > Fab-user mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user > -- Jeff Forcier Unix sysadmin; Python/Ruby engineer http://bitprophet.org _______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
