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.
Related
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 used indentation method in the code but it throws a error. Need solution please. My python version is Python 2.7.15+
Code:
import textwrap
s = 'hello\n\n \nworld'
s1 = textwrap.indent(text=s, prefix=' ')
print (s1)
print ("\n")
s2 = textwrap.indent(text=s, prefix='+ ', predicate=lambda line: True)
print (s2)
Code is taken from geeksforgeeks
Output Error:
python Textwrap5.py
Traceback (most recent call last):
File "Textwrap5.py", line 4, in <module>
s1 = textwrap.indent(text=s, prefix=' ')
AttributeError: 'module' object has no attribute 'indent'
It might be that your file is located in a directory called textwrap or you have other file called textwrap in the same or parent directory.
Try changing the directory name or the file and see if it works
Python2.7, textwrap doesn't have indent function available.
Either use initial_indent or subsequent_indent as per your requirement OR upgrade to Python3.x
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 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()