I am trying to import blf file using can.BLFReader module.
buf python shows 'AttributeError'.
this is the code.
import can
filename = "test.blf"
can_log = can.BLFReader(filename)
for msg in logging:
print(msg)
AttributeError: module 'can' has no attribute 'BLFReader'
and the file name is not 'can'
what is the reason?
It seems to be a problem with python3 version if you run as you can see in the attached image with python it will work
Related
I get the following error when I try to run the script for the VEDm filter in vmtk:
[location] line 149, in ApplyVEDManniesing
vesselness = vtkvmtk.vtkvmtkVesselEnhancingDiffusion3DImageFilter()
AttributeError: 'module' object has no attribute 'vtkvmtkVesselEnhancingDiffusion3DImageFilter'
I tried to run the code in my Python 3.6 environment, instead of 2.7 where I currently work in. But it gave the same error.
The other filters (Sato, Frangi, VED) were completed successfully and are represented in the same python-file vmtkimagevesselenhancement.py.
Can someone help me to find the problem?
Edit: this is what the beginning of the code looks like:
from __future__ import absolute_import #NEEDS TO STAY AS TOP LEVEL MODULE FOR Py2-3 COMPATIBILITY
import vtk
import sys
import pypes
import vtkvmtk
The filename where the line 149 doesn't work is vmtkimagevesselenhancement.py and is imported with the vmtk download.
i'm having a os library error, and it seems that there aren't much info about it on the net. When i try to create a folder in ubuntu 14.04 using my python script:
from os import *
ncpath = "lol"
if not path.exists(ncpath):
makedirs(path,0755)
this error is returned:
File "/home/user/anaconda2/lib/python2.7/posixpath.py", line 85, in split
i = p.rfind('/') + 1
AttributeError: 'module' object has no attribute 'rfind'
can someone help me figure out what's going on ?
Here:
makedirs(path,0755)
You are passing the path module itself instead ncpath which is your string.
I try to coonect to API of Autodesk Inventor with Python. I can create a new file but then an error aooears here:
import os
import win32com.client
from win32com.client import constants
from win32com.client import gencache
os.system(r'C://Programm Files/Autodesk/Inventor 2014/Bin/Inventor.exe')
invApp = win32com.client.Dispatch("Inventor.Application")
invApp.Visible = True
mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
**invApp = mod.Application(invApp)**
oAssemblyDoc=invApp.Documents.Add(constants.kAssemblyDocumentObject, "", True)
asd = invApp.Documents.Add(constants.kPartDocumentObject,"",True)
qwe=invApp.Documents.Item(asd)
oAss = oAssemblyDoc.Activate
There ir an error in the selected line:
TypeError: 'module' object is not callable
I am a novice in Python and I can't understand what is the error. Can anybody help me?
I see that the win32com gencache early binding produces some subfolders. This seems to work with:
invApp = mod.Application.Application(invApp)
I found that makepy.py had to be run with -i command option first time, then re-run to capture the full structure.
I downloaded a python project from github:
to work with interface file of ubuntu.
the problem is when I try to use the module as the Readme said I get this:
Traceback (most recent call last):
File "./ss.py", line 7, in <module>
adapters = debinterface.interfaces()
AttributeError: 'module' object has no attribute 'interfaces'
my ss.py script is:
#!/usr/bin/python
import debinterface
import sys
sys.path.append("/home/ed/Downloads/netpy/")
sys.path.append("/home/ed/Downloads/netpy/debinterface/")
adapters = debinterface.interfaces()
I run this script within "/home/ed/Downloads/netpy/" that consists of "debinterface". I have to say that I tried that script without "sys.path.append" but nothing changed, even I changed the module name "debinterface" to "debeh" but again nothing changed too.
what is my problem?
This looks like a bug in the documentation or the package code to me. You can use
from debinterface.interfaces import interfaces
and then refer to your the interface class with
adapters = interfaces()
or edit debinterface/__init__.py to do the import of interface module for you when you import the debinterface package. Add the line
from interfaces import interfaces
to the __init__.py file.
Well, I got it working doing the following:
Downloaded the zip from github;
Extracted the zip and renamed it to debinterfaces;
Created a python module in the same directory that debinterfaces folder is;
Changed the import statement:
from debinterface.interfaces import interfaces
And finally, called interfaces:
adapters = interfaces()
For this problem (stackoverflow.com/questions/4086435/), I tried to make a Python 3 version of the library python-websocket (github.com/mtah/python-websocket/), here is my code: https://gist.github.com/663175.
Blender comes with his own Python 3.1 package, so I added my file directly in its «site-packages» folder. I get this error now:
Traceback (most recent call last):
File "websocket.py", line 6, in
AttributeError: 'module' object has no attribute 'WebSocket'
when running this code in Blender:
import sys, os, asyncore, websocket
def msg_handler(msg):
print(msg)
socket = websocket.WebSocket('ws://localhost:8080/', onmessage=msg_handler)
socket.onopen = lambda: socket.send('Hello world!')
try:
asyncore.loop()
except KeyboardInterrupt:
socket.close()
I found that a __init__.py is needed so I added but it didn't help…
What I am doing wrong here ? Thanks for your help.
It looks like you called your script websocket.py, so the import of websocket finds the script itself, instead of the installed module by that name. Rename the script to something else (and if it created a websocket.pyc file, delete that.)