B Welch
B Welch

Reputation: 15

Global name 'paramiko' not defined when using module in web2py

I am running the source version of web2py from an Ubuntu VM and Python 2.7. I'm trying to use the Paramiko library for SSH functionality, but the following code gives this error:

Code

from paramiko import client

Error

Traceback (most recent call last):
  File "/home/localadmin/scanme/gluon/restricted.py", line 227, in restricted
    exec ccode in environment
  File "/home/localadmin/scanme/applications/nmap/controllers/default.py", line 418, in <module>
  File "/home/localadmin/scanme/gluon/globals.py", line 417, in <lambda>
    self._caller = lambda f: f()
  File "/home/localadmin/scanme/applications/nmap/controllers/default.py", line 50, in login
    except paramiko.ssh_exception.AuthenticationException:
NameError: global name 'paramiko' is not defined

What is confusing me is that importing and using the paramiko library works perfectly fine on my system when I run Python outside of web2py.

I thought that all modules available in my local Python install were supposed to be available in web2py when using the source version. This is how i launched the web server from the command line:

python2.7 web2py.py

Does anyone know what may be causing this issue? It's worth noting that I have not found a "paramiko" directory on my system after installing the library like I have with other modules that are working in web2py.

Upvotes: 0

Views: 7813

Answers (1)

Anthony
Anthony

Reputation: 25536

Your import statement is:

from paramiko import client

But in your code, you have:

except paramiko.ssh_exception.AuthenticationException

In order to reference paramiko, you must import it:

import paramiko

Upvotes: 4

Related Questions