[Tutor] import failure

Mats Wichmann mats at wichmann.us
Fri Feb 22 12:48:10 EST 2019


On 2/22/19 9:55 AM, Alex Kleider wrote:

> (p2) alex at one:$ python src/gdata/oauth/rsa.py
> key_factory = <module 'tlslite.utils.keyfactory' from 
> '/home/alex/.virtualenvs/p2/local/lib/python2.7/site-packages/tlslite/utils/keyfactory.pyc'> 
> 
> (p2) alex at one:$ python
> Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
> [GCC 7.3.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> from tlslite.utils import keyfactory
>>>>
> 
> Details: The initial run failed because of unavailability of a module.
> A little reading led to the discovery that it could be easily installed
> using pip but after doing so: Still the same failure.
> Running the interpreter proves that the module is now available but the
> test still fails.
> Adding a bit of code to the bottom of the failing module shows that it
> in fact can import the module in question.
> Ran the interpreter again just to be sure that the function is available
> and indeed it is.
> I don't understand how this could be possible.
> 
> Any suggestions as to what the problem might be or how to investigate
> further would be very much appreciated.
> 
> Cheers,
> Alex

pip installs are specific to the interpreter, you're probably getting a 
mismatch there.

Rule one: install this way:

python -m pip install sheepdip

that way you're sure the pip matches the python and things go in the 
expected place.

Rule 2:
you can do some inspection by printing the values of sys.executable and 
sys.path both in your interactive environment where it works and in your 
script where it doesn't work.

My guess is you'll find a mismatch... but this is only surmise, 
something to try out, we can't see your precise environment.





More information about the Tutor mailing list