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.
Related
I am trying to apply patch to subprocess library. Using following script and get the error:
TypeError: unsupported operand type(s) for -: 'module' and 'module'
os.chdir("C:/Users/Downloads")
import patch
patch -subprocess < issue_28168_03.patch
I downloaded the patch from https://bugs.python.org/issue28168
Need help with the error.
I was actually trying to apply the patch to fix issues with Uninterruptible subprocess when opening an exe file. I fixed it using following script.
import subprocess
import time
binary_path = 'path/file.exe'
args = 'arguments' # arbitrary
call_str = '{} {}'.format(binary_path, args)
proc = subprocess.Popen(call_str)
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
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 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()