vedo icon indicating copy to clipboard operation
vedo copied to clipboard

AttributeError: 'NoneType' object has no attribute 'pos'

Open Anagabrielamantilla opened this issue 1 year ago • 7 comments

Hi, I installed vedo2024.5.1+dev14 a I was trying to do a 3D plot. However, I got this error:

AttributeError: 'NoneType' object has no attribute 'pos'

If I run my script from anaconda prompt the plot showed without problems, but if I use an IDE as spyder or visual studio code the error appears. The specific line where the error appears is:

plot3D = Slicer3DPlotter(vol) plt.show()

Can you please help me to fix the error? I am using anaconda on Windows 11

Anagabrielamantilla avatar May 15 '24 03:05 Anagabrielamantilla

Hi, I might have introduced a bug in the dev version .... Is the error also showing up in the released version?

pip uninstall vedo
pip install vedo -U

marcomusy avatar May 15 '24 12:05 marcomusy

it did not work. I got this error now:

ImportError: cannot import name 'Volume' from 'vedo' (unknown location)

Anagabrielamantilla avatar May 15 '24 14:05 Anagabrielamantilla

I think there must be something else going wrong there.. you should post a minimal script with the complete error message, e.g

from vedo import Volume
vol= Volume()
print(vol)

Does it work from command line eg.

vedo --run numpy2volume0

marcomusy avatar May 15 '24 14:05 marcomusy

sure, here is my complete code:

import numpy as np
from vedo import Volume
from vedo.applications import Slicer3DPlotter
import matplotlib.pyplot as plt
f = open('data.bin', 'rb') 
content = f.read() 
f.close() 
data = np.frombuffer(content, np.float32)
print(data)

data_3d = data.reshape((200,200,700),order='F')

vol = Volume(data_3d)

plot3D = Slicer3DPlotter(vol)

plot3D.show()

I have numpy 1.26.4, vedo 2024.5.1 and matplotlib 3.8.4

Anagabrielamantilla avatar May 15 '24 15:05 Anagabrielamantilla

You did not show the exact error message. Can you reproduce this?

import numpy as np
from vedo import Volume
from vedo.applications import Slicer3DPlotter

data = np.zeros([70, 80, 90], dtype=np.uint8)
data[ 0:30,  0:30,  0:30] = 1
data[30:50, 30:60, 30:70] = 2
data[50:70, 60:80, 70:90] = 3

vol = Volume(data)

plot3D = Slicer3DPlotter(vol)
plot3D.show()

Screenshot from 2024-05-15 20-19-59

marcomusy avatar May 15 '24 18:05 marcomusy

I reproduced your code in spyder with vedo 2024.5.1 and I get the following error:

AttributeError: 'NoneType' object has no attribute 'pos'

If I use:

pip uninstall vedo
pip install vedo -U

and run the same code with spyder I get the following error: ImportError: cannot import name 'Volume' from 'vedo' (unknown location)

Anagabrielamantilla avatar May 15 '24 18:05 Anagabrielamantilla

The second error message points to a problem in your anaconda installation. I just run the above script in a spyder version 5 console and it runs normally..

marcomusy avatar May 15 '24 18:05 marcomusy

Let me know if need further help on this. I'm closing the issue for the moment.

marcomusy avatar Jun 13 '24 18:06 marcomusy