On Windows 8, Python 2.7, and PyVISA 1.4:
I have tried multiple installs, most recently using easy_install.
When I enter import visa, it seems to work, and I do not get an error message.
When I try to run 'lib = visa.VisaLibrary()', I get the following error returned:
>>> lib = visa.VisaLibrary()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VisaLibrary'
>>>
I clearly have some functionality, as the resource manager exists:
>>> rm = visa.ResourceManager()
>>> print(rm)
ResourceManager()
So, why does it seem like I do not have access to all VISA functionality?
VisaLibrary is a function introduced in version 1.5. For 1.4, you have visa_library.
To make sure everything is correct, you could run the tests; usually pyvisa.test().
Related
Traceback (most recent call last):
File "E:\whitedark\Python\Xample\datetime.py", line 1, in <module>
import datetime
File "E:\whitedark\Python\Xample\datetime.py", line 3, in <module>
todate = datetime.datetime.now()
AttributeError: partially initialized module 'datetime' has no attribute 'now' (most like
ly due to a circular import)
My code is simple. Just ...
import datetime
todate = datetime.datetime.now()
print(todate)
That is all. In the example they show, it works. I use Thonny. The code can run perfectly inside Thonny which use python 3.7.9. I don't use F5 to run code. The shell blocks half of my code. I can't see all. So, I use cmd which uses python 3.9.5. Should I uninstall python 3.9.5 and install 3.7.9? or is there another way? I think the higher version is better. Not? or did they remove 'now' attribute in 3.9.5? if so, is there any better site to learn python?
I have a problem very similar to this one but I'm not about using gcloud but I'm trying to run pyqtdeploy.
I'm facing a strange problem: Running
>>> import importlib
>>> importlib.util.spec_from_file_location()
gives me
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'util'
..using Python3.8.6 with importlib-1.0.4 running on a Debian 10 +testing machine
while the exact same commands on Fedora 32 also running Python3.8.6 with importlib-1.0.4 let me use importlib.util:
>>> importlib.util.spec_from_file_location()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: spec_from_file_location() missing 1 required positional argument: 'name'
Why can the exact same module have an attribute on one system and not on the other?
And how do I make pyqtdeploy (and thus importlib.util) work as expected?
Background: I'm currently trying to run pyqtdeploy inside a Docker container but despite I'm using the same versions of Python and importlib it will run on the Fedora host but not inside the container..
user2357112 offers sound advice:
from importlib import util
Use instead e.g. from importlib import util as iutil and then iutil.spec_from_file_location().
I have followed https://pypi.python.org/pypi/openvas.omplib#installing-openvas-omplib with no luck. Below is the code they suggest (I used):
from openvas.omplib import *
manager = openvas.omplib.OMPClient(host = sensor)
manager.open(USER,PASSWORD)
I get the following error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
manager = openvas.omplib.OMPClient(host=sensor)
NameError: name = 'openvas' is not defined
It seems the library is not installing correctly or all the way. To install, I ran:
easy_install openvas.omplib
Any ideas?
I have also tried Openvas_lib 1.0 (another form). This one also runs into errors. (yes I have the variables set to something)
from openvas_lib import VulnscanManager, VulnscanException
scan = VulnscanManager("localhost",USER,PASSWORD,9392)
scan.launch_scan(target,profile="empty")
Here is an image of my errors
It seems openvas wasn't updated for Kali 2.0 yet. However, openvas_lib works perfectly on Kali's older version. Hopefully they update openvas_lib for the newer version of kali soon.
I installed redis-py on CentOS and Ubuntu. On both I get the same error when trying to access it.
redis-py AttributeError: 'module' object has no attribute
If I use the python prompt in the same directory as the source this will work:
>>> import redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
but if I change directories it will give the error.
>>> import redis
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "redis.py", line 4, in <module>
print redis.__version__
AttributeError: 'module' object has no attribute '__version__'
Trying with a .py script always gives the error. Any idea what I'm doing wrong, and how to fix it. Probably a newbie Python thing...
You're naming a module you're working on redis.py and Python is importing that instead of the real redis module. Don't do that, or change sys.path to make sure the current working directory is last rather than first in the lists of directories to search.
i have this error in tornado and it was because i install redis on python 2.7 and install in python3 too , i uninstall redis from python2.7 and re_install in python3 and solve the Problem!
I'm trying to run a simple code to test that I have installed correctly pyexiv2 in my computer. I'm using python 2.6.6. on windows 7 64 bit
So I run this simple code:
import pyexiv2
print pyexiv2.exiv2_version_info
and I get this error:
Traceback (most recent call last):
File "C:/Users/Usuario/Desktop/pyexiv2/pyexiv2.py", line 1, in <module>
import pyexiv2
File "C:\Users\Usuario\Desktop\pyexiv2\pyexiv2.py", line 3, in <module>
print pyexiv2.version_info
AttributeError: 'module' object has no attribute 'version_info'
How can I fix that? Thank you
You named your own file pyexiv2.py as well; rename it or delete it, as it is being imported instead of the installed module.