Skip to content

ERR: in python >= 3.5 use FileNotFoundError instead of OSError #14086

Closed
@brunobeltran

Description

@brunobeltran

Simple to reproduce:

import pandas as pd
try:
    pd.read_csv('this_file_does_not_exist.csv')
except FileNotFoundError:
    print('This should execute.')

Instead, I get an OSError, which tells me in text that OSError: File b'this_file_does_not_exist.csv' does not exist.

https://docs.python.org/3.5/library/exceptions.html seems to suggest that OSError now has various subclasses, e.g. FileNotFoundError, for specific errors such as this one.

Output of pd.show_versions():

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-31-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 23.0.0
Cython: None
numpy: 1.11.1
scipy: 0.18.0
statsmodels: None
xarray: None
IPython: 5.0.0
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions