I want to use Python and Spectral library to open a hyperspectral image as ENVI file (.hdr + .dat), rewrite some bands and then save the file in the same format. I have problem with this:

"TypeError: 'BipFile' object does not support item assignment"

I've got this response when I want to rewrite the band or change the file. Do you know of some solution or advice which could help?

#open file 
src = envi.open("C:\soubory_pix\SASI_1.pix.hdr", "C:\soubory_pix\SASI_1.pix")
src_band = src
#rewrite band
src_band[:, 0:319, 96] = src[:, 0:319, 96] * koef_men

Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: 'BipFile' object does not support item assignment
  • Why are you using a .pix versus perhaps a .int, when you use the envi.open?
    – whyzar
    Oct 16, 2017 at 13:49

1 Answer 1


finaly I find out solution. If you have similar problem, you can load imaage to memmap like this. Then you can work with ENVI file and for saving just delete variable.

src = envi.open(filename_hdr)
img = src.open_memmap(writable=True)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.