0

I'm running an url in django that will execfile(xxx.py). I'm running this django via apache server on windows with mod_wsgi module.

Here is it my view.py in django

def list(request):
execfile('D:/xampp/htdocs/djangoproj/djangoapp/list.py')

This is my list.py

#!/usr/bin/python 
from fabric.api import execute
from fabfile import *

execute(makedir)

And this is my makedir on fabfile

env.hosts = ['x@xxx.xxx.xxx.xxx']
env.password = 'xxxx'
def makedir():
    run('mkdir test')

When i'm open url that pointed to list, i always got error 500.

With this error_log

[Fri Aug 15 11:33:03 2014] [error] Traceback (most recent call last):
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\fabric\\network.py", line 24, in <module>
[Fri Aug 15 11:33:03 2014] [error]     import paramiko as ssh
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\paramiko\\__init__.py", line 31, in <module>
[Fri Aug 15 11:33:03 2014] [error]     from paramiko.transport import SecurityOptions, Transport
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\paramiko\\transport.py", line 47, in <module>
[Fri Aug 15 11:33:03 2014] [error]     from paramiko.dsskey import DSSKey
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\paramiko\\dsskey.py", line 26, in <module>
[Fri Aug 15 11:33:03 2014] [error]     from Crypto.PublicKey import DSA
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\Crypto\\PublicKey\\DSA.py", line 34, in <module>
[Fri Aug 15 11:33:03 2014] [error]     from Crypto import Random
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\Crypto\\Random\\__init__.py", line 28, in <module>
[Fri Aug 15 11:33:03 2014] [error]     import OSRNG
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\Crypto\\Random\\OSRNG\\__init__.py", line 34, in <module>
[Fri Aug 15 11:33:03 2014] [error]     from Crypto.Random.OSRNG.nt import new
[Fri Aug 15 11:33:03 2014] [error]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\Crypto\\Random\\OSRNG\\nt.py", line 28, in <module>
[Fri Aug 15 11:33:03 2014] [error]     import winrandom
[Fri Aug 15 11:33:03 2014] [error] ImportError: DLL load failed: The specified module could not be found.
[Fri Aug 15 11:33:03 2014] [error] 
[Fri Aug 15 11:33:03 2014] [error] There was a problem importing our SSH library (see traceback above).
[Fri Aug 15 11:33:03 2014] [error] Please make sure all dependencies are installed and importable.
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1] mod_wsgi (pid=5564): SystemExit exception raised by WSGI script 'D:/xampp/htdocs/blog/mod.wsgi' ignored.
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1] Traceback (most recent call last):
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 206, in __call__
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     response = self.get_response(request)
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 112, in get_response
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\xampp\\htdocs\\blog\\blog1\\views.py", line 17, in list
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     execfile('D:/xampp/htdocs/djangoproj/djangoapp/list.py')
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:/xampp/htdocs/djangoproj/djangoapp/list.py", line 2, in <module>
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     from fabric.api import execute
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\fabric\\api.py", line 9, in <module>
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     from fabric.context_managers import (cd, hide, settings, show, path, prefix,
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\fabric\\context_managers.py", line 42, in <module>
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     from fabric.state import output, win32, connections, env
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\fabric\\state.py", line 9, in <module>
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     from fabric.network import HostConnectionCache, ssh
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]   File "D:\\FilePkl\\Python27\\lib\\site-packages\\fabric\\network.py", line 33, in <module>
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1]     sys.exit(1)
[Fri Aug 15 11:33:03 2014] [error] [client 127.0.0.1] SystemExit: 1

Can someone help me to solve this? thanks before

  • you want to look at `ImportError: cannot import name util` and work that out. – monkut Aug 15 '14 at 04:08
  • Take a look at this question: http://stackoverflow.com/questions/5788891/execfile-with-argument-in-python-shell – cyk Aug 15 '14 at 04:11
  • edited error_log with the actual error_logs from the script above. what can i do to solve `problem importing our SSH library` – muhammad irfan Aug 15 '14 at 04:38
  • How did you install Fabric, Paramiko, and PyCrypto? It looks like one of them (PyCrypto) wasn't installed right, and that's what you need to fix. – abarnert Aug 15 '14 at 05:08
  • Also, this will be a lot easier to debug if you just run your code in a normal script, or import the module into an interactive interpreter, instead of trying to do it through Django. – abarnert Aug 15 '14 at 05:08
  • refer to `pip list` on cmd i have installed this : Django (1.6.5) django-bootstrap-toolkit (2.15.0) ecdsa (0.11) Fabric (1.9.0) MySQL-Connector-Python (1.2.2) MySQL-python (1.2.3) paramiko (1.14.0) pip (1.5.6) pycrypto (2.1.0) setuptools (5.4.2) virtualenv (1.11.6) – muhammad irfan Aug 15 '14 at 05:36
  • possible duplicate of [Paramiko and Crypto Import Error: import winrandom (python)](http://stackoverflow.com/questions/6332653/paramiko-and-crypto-import-error-import-winrandom-python) – wRAR Aug 15 '14 at 07:17

0 Answers0