Question

I am trying to parse a fasta file in Biopython using the following code.How can I solve this error?

from Bio import SeqIO
handle = open("C:/Users/Desktop/kk.fasta", "rU")



File "<pyshell#19>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'kk.fasta'

I am getting the above error. But my file is already there. I am using windows7 OS , python 2.7 and Biopython 1.57. Any suggestions please.

Was it helpful?

Solution

try:

import os
print os.path.isfile(r"C:\Users\Desktop\kk.fasta")

if the output is true, you can try to replace the string in the original code and see if it works. If not, make sure there is no typo in the path.

the small r means raw. It will escape all \ to \\ to make sure the path is valid (\n won't become a newline)

OTHER TIPS

Your path is wrong.

Open up explorer and put in this path:

c:\Users\

This might help you to correct the path. The next directory below Users will be a username, or Default, not Desktop.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top