I am having trouble using the skimage ImageCollection (http://scikit-image.org/docs/dev/api/skimage.io.html#imagecollection) object in Python3. For example, in python 2,7, I was using it as follows:
import skimage.io as io
files = io.ImageCollection('/home/luca/sequence/*.*)
method_do_something(files[0])
This worked fine. When I use it in Python 3.4, the creation of the ImageCollection object works fine and len(files) returns the correct amount of files.
However, when I try the files[0] call, I get the following error:
AttributeError: 'builtin_function_or_method' object has no attribute 'keys'
I was wondering if anyone knows of a workaround that might work on both 2.7 and python 3.x
Related
I am three weeks into my independent study Python course, and am having trouble getting passed an issue. I am trying to use the function enterbox() from easygui I write:
import easygui
value = easygui.enterbox("say something")
And when I run it I get the error:
**AttributeError: 'module' object has no attribute 'enterbox'
Does anyone know why this may be happening? Thanks! (I'm using version 2.7)
I have compiled the aruco library as stated here github link for aurco library
I have checked it has compiled successfully as i can import it in python without any error and to check i have run the example.py script also it's working but when i wrote this code
import cv2
import numpy as np
import aruco
Dictionary = aruco.getPredefinedDictionary(aruco.PREDEFINED_DICTIONARY_NAME(DICT_5X5_250=6))
aruco.drawMarker(Dictionary,5,250,markerImage,1)
aruco.drawMarker(Dictionary,10,250,markerImage,1)
aruco.drawMarker(Dictionary,20,250,markerImage,1)
aruco.drawMarker(Dictionary,25,250,markerImage,1)
aruco.drawMarker(Dictionary,50,250,markerImage,1)
aruco.drawMarker(Dictionary,100,250,markerImage,1)
aruco.drawMarker(Dictionary,200,250,markerImage,1)
cv2.imshow("markers",markerImage)
cv2.waitKey(0)
cv2.imgwrite(marker.jpg,markerImage)
it throws error
Traceback (most recent call last): File "drawmarker.py", line 7, in
Dictionary = aruco.getPredefinedDictionary(aruco.PREDEFINED_DICTIONARY_NAME(DICT_5X5_250=6))
AttributeError: 'module' object has no attribute
'getPredefinedDictionary'
can someone please let me know what am i doing wrong, is this module not imported in python version of aruco ?
maybe you should try this "aruco.DICT_5X5_250" as parameter, like...
dict = aruco.getPredefinedDictionary( aruco.DICT_5X5_250 )
it worked for me :)
I'm trying to use cubehelix in python however I've been getting simple problems which I don't think should be showing up. The code I'm using is the following:
import matplotlib.pyplot as plt
import numpy as np
import cubehelix
cx1 = cubehelix.cmap(reverse=True)
alplot = plt.imshow(rtotal_rotated,vmax=1100,extent[-21,19,23,-17],cmap=cx1)
However the following error comes up when I run the code:
AttributeError: 'module' object has no attribute 'cmap'
I know this can't be right since I'm simply following the code from this tutorial
http://www.ifweassume.com/2014/04/cubehelix-colormap-for-python.html
So I'm not sure why it's breaking.
Very like that the script imports itself, i.e. your script is named cubehelix.py. So, if you have file named cubehelix.py in your current working directory, rename it to my_cubehelix.py and try again.
I'm using python sklearn RandomForestClassifier and try to export decisiontrees.
The basic code is as following:
from sklearn import tree
with open(dot_file_name, 'w') as my_file:
tree.export_graphviz(tree1, out_file = my_file,feature_names = feature_names)
After run the python script, following error show up:
Attribute error: 'DecisionTreeClassifier' object has no attribute 'export_graphviz'
I'm using python 2.7. Is it because of the version of python? Do I have to use python 3.0?
That's because you used somewhere tree name as name for DecisionTreeClassifier. Use another name there.
When I type this code into a python shell it works perfectly fine but within a program it gives an error.
import os
h = os.environ['HOME']
within a script it gives this error:
AttributeError: 'str' object has no attribute 'environ'
Why is this happening and is there any way I can fix it?
(I'm kinda just learning python so I dont know much. Google didn't help)
Somewhere, you've created a string and named it os. The . is the attribute lookup operator, so it's complaining about the thing to the left of the ., in this case, os.
are you sure that between import os and h = os.environ['HOME'] you did not use os as a variable for a string?
edit: If you do not work with an editor with a debugger (e.g. Eclipse with PyDev), try to find out from which point os is no longer a module by calling print(os) at some key points in your code