0

I meet a strange problem:

I have installed paste successfully. And "import paste" is ok.

But i noticed imp can not find it. "imp.find_module('paste')" always gives "ImportError: No module named paste".

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import imp
>>> imp.find_module('paste')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named paste
>>> import paste

I have tested this on three different machines (Ubuntu14.04, Windows 10, Windows XP), all have similar problem.

2 Answers 2

1

I have duplicated this behavior. It seems a little odd to me. The docs describe some slight differences in find_module()'s behavior, but it doesn't seem to highlight anything matching this discrepancy. I suspect it's a bug or perhaps by design but not well documented.

The paste package in particular uses a pth configuration file. You can disable this behavior with -S to see its effect.

$ python -c 'import paste' && echo found
found

$ python -S -c 'import paste' && echo found
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named paste
0

The main problem seems that paste module doesnt have an __init__.py file

If you create it manually the problem is solved

2
  • where should you put the file? Commented Jul 23, 2017 at 18:12
  • @DjDac in the paste module directory.
    – Bijoy
    Commented Jul 24, 2017 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.