Or do relative imports:

from .static.pycrypto.lib import Crypto
from .static.paramiko import paramiko


-- 
Lemuel


On Aug 28, 2013, at 16:19, Andrew Latham <[email protected]> wrote:

> Thanks, Todd, that is the area I researched last night. Will report back on 
> success or failure.
> 
> On Aug 28, 2013 6:53 AM, "Todd DeLuca" <[email protected]> wrote:
>> You can try prepending your package directories to sys.path and I think they 
>> will be found first.  Though the right way to use packages that are 
>> different from the system-wide ones is probably to use a virtualenv.
>> 
>> 
>> 
>> On Tue, Aug 27, 2013 at 10:40 PM, Andrew Latham <[email protected]> wrote:
>>> Ok, back to the drawing board. The imports of paramiko and pycrypto
>>> were also defaulting to the system versions.  I will do this another
>>> way.
>>> 
>>> Just in case anyone cares, I am trying to make a user-space drop in to
>>> manage some servers in a very restricted environment.  It is just a
>>> hobby project at the moment.
>>> 
>>> 
>>> On Tue, Aug 27, 2013 at 9:53 PM, Andrew Latham <[email protected]> wrote:
>>> > Ok, finally set down to get some hacking done..  The example by Todd
>>> > shows the fabric version installed on the system and not the version
>>> > in the git pull.  Back to square one...
>>> >
>>> > On Tue, Aug 27, 2013 at 11:38 AM, Andrew Latham <[email protected]> wrote:
>>> >> Thanks guys, I think I have a handle on it. Will report back on user 
>>> >> space
>>> >> fabric usage...
>>> >>
>>> >> On Aug 26, 2013 11:12 AM, "Jeff Forcier" <[email protected]> wrote:
>>> >>>
>>> >>> 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
>>> >
>>> >
>>> >
>>> > --
>>> > ~ Andrew "lathama" Latham [email protected] http://lathama.net ~
>>> 
>>> 
>>> 
>>> --
>>> ~ 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
> _______________________________________________
> Fab-user mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/fab-user
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to