My os is Ubuntu 12.04.
I install the kvm virt-manager and python.
I want to use python code to control the vm on kvm.
but my code import libvirt has something wrong...
Here is my code :
import libvirt
import time
import threading
import paramiko
import os
import commands
import signal
numVM = 1
hostname=['VM-01']
port=22
VMLoadAve={}
def monitor():
.....
while True:
monitor()
time.sleep(MAXDURATION)
Traceback (most recent call last): File "test1.py", line 1, in
import libvirt ImportError: No module named libvirt
I have installed the python-libvirt, libvirt-bin
what other reasons may do this happened?
I am a newest for this. thanks for your help ~ :)
For the sake of historicaly record, 'python-libvirt' is the correct deb package for the python 2 binding, while python3-libvirt gives you the corresponding python 3 binding to libvirt.
Related
I have a python file named "test_module.py" with the code
from scapy.all import *
and when i execute the file with python test_module.py the module is getting imported successfully but when I run the file using the command sudo python test_module.py it is saying the error
Traceback (most recent call last):
File "test_module.py", line 1, in <module>
from scapy.all import *
ImportError: No module named scapy.all
System info:-
Linux mint 20
Python 2.7.18
So, Please help me to fix this issue.
Did you do
sudo python -m pip install scapy
first ? your issue is likely just having two separate environments
perhaps, try :
pip install scapy
import sys
# and take the correct Path to your scapy , example :
sys.path.insert(1, '/home/Your NAME/anaconda3/lib/python3.8/site-packages/')
I want to know how to import scapy and use arping. I have tried import scapy.all and some others but has no seemed to work and I keep getting the error...
Traceback (most recent call last):
File "network_scanner.py", line 3, in <module>
from scapy.all import arping
ImportError: No module named scapy.all
This the code I am running.
#!/usr/bin/env python
from scapy.all import arping
def scan(ip):
arping(ip)
scan('10.0.2.1')
If someone could help me that would be amazing!
try to install scapy for ur python version. it seems like none scapy installed in your python lib.
I am trying to write a server using twisted on python.
This is the head of my file :
from twisted.internet.protocol import Factory, Protocol
from twisted.internet.endpoints import TCP4ServerEndpoint
from twisted.internet import reactor
The first and the last import work perfectly. I get an error when trying to run the second import with the following traceback :
Traceback (most recent call last):
File "<ipython-input-1-c0d6286e105b>", line 1, in <module>
from twisted.internet.endpoints import TCP4ServerEndpoint
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\endpoints.py", line 34, in <module>
from twisted.internet.stdio import StandardIO, PipeAddress
File "C:\Anaconda3\lib\site-packages\twisted-15.5.0-py3.4.egg\twisted\internet\stdio.py", line 30, in <module>
from twisted.internet import _win32stdio
ImportError: cannot import name '_win32stdio'
I've already tried solutions like installing pypiwin32 both manually (using whl file) and with pip install. But the problem is not solved.
I am working on windows 7 (yes !) with python 3.4.3 and Twisted 15.0
Thank you for your help.
You are using Python 3, and _win32stdio is not ported to Python 3. If you want the full set of Twisted functionality, you have to run Python 2 (PyPy 4.x+ recommended) for now.
You could install twisted-win with:
pip install twisted-win
From description:
Windows compatibility for Twisted, specifically for Scrapy
It works for me for win 7, python 3.5.2.
I'm struggling to get some python code using the python-brisa framework to work, the code is not written by me but should be straight forward.
from brisa.core.reactors import install_default_reactor
reactor = install_default_reactor()
from brisa.core.threaded_call import run_async_function
import xml.etree.ElementTree as ET
from time import sleep
import sys, os
import sonos
import knx
Howewer after installing the frameworks I get
Traceback (most recent call last):
File "knxsonos.py", line 24, in <module>
reactor = install_default_reactor()
File "/usr/local/lib/python2.7/dist-packages/brisa/core/reactors/__init__.py", line 14, in install_default_reactor
return GLib2Reactor()
NameError: global name 'GLib2Reactor' is not defined
I have been looking both stack overflow, and googling for days without finding a solution.
Anyone??, help would be greatly appreciated...
Here's some possibilities:
GLib2Reactor doesn't return anything - Then your code is wrong
GLib2Reactor is not declared - try this:
x = GLib2Reactor()
return x
GLib2Reactor has to be imported - just import it
my best advice: read the docs
When I saw this problem on an Ubuntu Trusty (14.04) system, it was caused by import gobject failing. The fix was to install the correct package:
sudo apt-get install python-gobject-2
This package is marked as deprecated, so on newer distributions it might be necessary to install the python-gi package instead, and then modify the callers to use the new names:
from gi.repository import GObject
Hi i have installed WAMP server(Mysql , apache ,php) and also installed "Python" separately.Now i am trying to connect to that database using python code .
This is my python code:
#!C:\Python32\python.exe
import sys
import os
import cgi
import MySQLdb
import cgitb
import SecureDb
cgitb.enable()
print ("Content-type: text/plain\n\n");
conn= MySQLdb.connect(host = SecureDb.host ,user =SecureDb.user ,passwd=SecureDb.password ,db=SecureDb.database)
cursor=conn.cursor()
cursor.execute("select * from register where Name='Subburaj'")
result=cursor.fetchall()
cursor.close()
conn.close()
But this is showing an error:
Traceback (most recent call last):
File "C:\Users\Ponmani\Desktop\test.cgi", line 5, in <module>
import MySQLdb
File "C:\Python32\lib\site-packages\MySQLdb\__init__.py", line 17, in <module>
from release import __version__, version_info, __author__
ImportError: No module named release
If anybody came across this problem please help me to solve this.Thanks in advance.
MYSQLdb doesn't come with python. It seems that you have to install it first from here. There's an executable here, if you are using windows 32. But it's for python 2.7. If you are using python 3.2 it gets more difficult. Here's an unofficial package that should work for 3.2.
EDIT:
Release module should be a part of mysqldb, my only guess is theres is still something wrong with the installation. Maybe subforlders weren't extracted correctly.You should try to reinstall.
EDIT: you can also check if you have release.py in the mysqldb directory. if you dont it is surely installation problem.
You Need to install MySQLdb Module
easy_install MySQL-python