IOError: [Errno 2] No such file or directory on Mac
Question: I've tried to open a file that does exist but I keep getting an error message
of:

    
    
    No such file or directory on Mac
    

I have made sure it is in the same directory as the python code. I've also
tried changing the name of the excel doc and whether the doc is `.xls` and
`.xlsx` but it has not worked.

Here are several versions I've tried, but so far they all give me the same
result.

    
    
    import os.path
    book = open(os.path.expanduser("~/Desktop/Crimes.xlsx"))
    

or

    
    
    import xlrd
    import os.path
    book = xlrd.open_workbook(os.path.join("/Users/caitlinwesterfield",'Crime.xls')
    

or

    
    
    import xlrd
    book = xlrd.open_workbook('Crime.xls')
    

or

    
    
    import xlrd
    book = open('/Users/caitlinwesterfield/Desktop/Crime.xls', "r")
    

or

    
    
    import xlrd
    book = open("~/Crime.xls", "r")
    

or

    
    
    import xlrd
    book = open(os.path.expanduser(r"~/Desktop/Crime.xls"))
    

or

    
    
    import xlrd
    book = open('Crime.xls')
    

or

    
    
    import xlrd
    book = open(os.path.expanduser("/Users/caitlinwesterfield/Desktop/Crime.xls"))
    

or

    
    
    import xlrd
    import os
    book = xlrd.open_workbook(os.path.join("/Users/caitlinwesterfield","TypesOfCrime.xls"))
    

or

    
    
    import xlrd
    book = xlrd.open_workbook("typesofcrime.xls")
    


Answer: Have you tried checking if there was a permissions issue?

Open up your terminal and cd to the right directory

    
    
    cd -l
    

Here is what those permissions mean:

    
    
    rwxrwxrwx  <-- r refers to read, w to write, and x to execute
    ---------  <-- a hyphen refers to the permission not existing 
    

[![enter image description
here](http://i.stack.imgur.com/xpdbm.png)](http://i.stack.imgur.com/xpdbm.png)

Try running:

    
    
    chmod 777 Crimes.xlsx
    # you might need to add sudo if you get permission error:
    sudo chmod 777 Crimes.xlsx
    

[image source and more info](http://www.techradar.com/how-
to/computing/apple/terminal-101-file-permissions-1305647)

[how to use the terminal](http://www.macworld.co.uk/feature/mac-software/get-
more-out-of-os-x-terminal-3608274/)

