marcelm / cutadapt

Cutadapt removes adapter sequences from sequencing reads
https://cutadapt.readthedocs.io
MIT License
502 stars 126 forks source link

Error in file.py, "OutStream" object does not have attribute 'buffer' #763

Closed karenyun closed 4 months ago

karenyun commented 4 months ago

When the program runs to close every file, it pops the following error: "OutStream" object does not have the attribute 'buffer'. Then I found a "if" in file.py, where it is "if bf is not sys.stdout.buffer". I use python3.9 and 3.10. they all have the error. I cannot figure out how to solve it. Could you please help with it? Thanks very much!

marcelm commented 4 months ago

Can you please describe exactly what you are doing?

I searched a bit and found that OutStream is something that exists in Jupyter notebooks. Did you run Cutadapt from within a Jupyter notebook? If so, how?

karenyun commented 4 months ago

Hi marcelm, thanks very much for the quick reply!

I use the code "mali-dual-crispr-pipeline" which uses the "cutadapt".

The code uses the "main" function in your "cli.py", and when I run the command under "mail-dual-crispr-pipeline", it pops out the error "OutStream" object does not have the attribute 'buffer', which because you use the "sys.stdout.buffer" in your "cli.py" and "file.py".

I changed all "sys.stdout.buffer" to None, and now it works. Thanks very much!

marcelm commented 4 months ago

Thanks for the additional information. Cutadapt is at the moment intended to be run from the command line, so importing it as a Python module is a bit outside of normal usage. However, I would like this to work in the future and have therefore fixed this problem now.

Replacing sys.stdout.buffer with None is also ok.