File txt: FileNotFoundError: [Errno 2] No such file or directory
Question: i have a txt file and if i try to open it python says:

    
    
    runfile('/Users/costanzanaldi/Desktop/tesi/Tesi_Naldi/COdice _Python/untitled0.py', wdir='/Users/costanzanaldi/Desktop/tesi/Tesi_Naldi/COdice _Python')
    
    Traceback (most recent call last):
    
      File "<ipython-input-30-b4bdfdd17ca2>", line 1, in <module>
        runfile('/Users/costanzanaldi/Desktop/tesi/Tesi_Naldi/COdice _Python/untitled0.py', wdir='/Users/costanzanaldi/Desktop/tesi/Tesi_Naldi/COdice _Python')
    
      File "/Users/costanzanaldi/anaconda/lib/python3.4/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 685, in runfile
        execfile(filename, namespace)
    
      File "/Users/costanzanaldi/anaconda/lib/python3.4/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 85, in execfile
        exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
    
      File "/Users/costanzanaldi/Desktop/tesi/Tesi_Naldi/COdice _Python/untitled0.py", line 13, in <module>
        in_file = open("POLO_SCIENTIFICO_(LAMMA).txt","r")
    
    FileNotFoundError: [Errno 2] No such file or directory: 'POLO_SCIENTIFICO_(LAMMA).txt'
    

1)the file EXISTS! 2)the path is correct! It is in the desktop!


Answer: You need to change your directory to your desktop in order to access the file.
You'd do that using the `os` module, like this:

    
    
    import os
    os.chdir("/path/to/Desktop")
    

