marcomusy / vedo

A python module for scientific analysis of 3D data based on VTK and Numpy
https://vedo.embl.es
MIT License
1.98k stars 257 forks source link

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

Closed Anagabrielamantilla closed 2 weeks ago

Anagabrielamantilla commented 1 month ago

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

marcomusy commented 1 month ago

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
Anagabrielamantilla commented 1 month ago

it did not work. I got this error now:

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

marcomusy commented 1 month ago

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
Anagabrielamantilla commented 1 month ago

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

marcomusy commented 1 month ago

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

Anagabrielamantilla commented 1 month ago

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)

marcomusy commented 1 month ago

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 commented 2 weeks ago

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