May
May

Reputation: 1167

Web2py: <type 'exceptions.ImportError'> (ImportError("Cannot import module 'applications.*.modules.paramiko'",)

I believe this problem has been addressed in various forums and in here also. And the acceptable solution seems to be using source version of web2py. And I am using it. I had setup web2py on my ubuntu machine by running the setup-web2py-ubuntu.sh .

Version

2.15.4-stable+timestamp.2017.09.02.04.02.22
(Running on Apache/2.4.18 (Ubuntu), Python 2.7.12)

But when i try to load my application, which uses paramiko and load of other python libraries, I get this error. Kindly help.

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/www-data/web2py/applications/rip/models/scheduler.py", line 3, in <module>
    import paramiko
  File "/home/www-data/web2py/gluon/custom_import.py", line 104, in custom_importer
    raise ImportError(e1, import_tb)  # there an import error in the module
ImportError: (ImportError("Cannot import module 'applications.rip.modules.paramiko'",), <traceback object at 0xac07eb6c>)

P.S: rip is my application name.

Upvotes: 0

Views: 1061

Answers (2)

DPalharini
DPalharini

Reputation: 523

Theoricaly web2py shall get any library installed inside the virtual env or inside the system path, according with this https://groups.google.com/u/1/g/web2py/c/piqB_l1T7pU.

As the link says if the lib works in the python shell shall work in web2py.

I had a similar problem, but I did not want to install the lib inside de folder modules. My problem was the web2py folder name, instead of using web2py I was using web2py2 (reference to python 2.7). Apparently web2py does not support it.

Upvotes: 0

May
May

Reputation: 1167

After going through the books, I came to know that we have to have the python libraries in the web2py modules directory.

sudo pip install paramiko --target /home/www-data/web2py/applications/<your_application_name>/modules

In case you want to install ANy package to that directory, which by default would have landed to site-packages, you can do this.

python setup.py install --prefix=/home/www-data/web2py/applications/<your_application>/modules

This worked for me perfectly.

Upvotes: 2

Related Questions