This happens if you are trying to open a file, but your path is a folder.
This can happen easily by mistake.
To defend against that, use:
import os path = r"my/path/to/file.txt" assert os.path.isfile(path) with open(path, "r") as f: pass
The assertion will fail if the path is actually of a folder.
Related Posts:
- filedialog, tkinter and opening files
- takes 1 positional argument but 2 were given
- How to install pip3 on Windows?
- How to pass arguments to a Button command in Tkinter?
- Python Setup Disabling Path Length Limit Pros and Cons?
- ‘pip3’ is not recognized as an internal or external command, operable program or batch file
- Pip – Fatal error in launcher: Unable to create process using ‘”‘
- Windows- Pyinstaller Error “failed to execute script ” When App Clicked
- Anaconda Installed but Cannot Launch Navigator
- How to clear Tkinter Canvas?
- How to know/change current directory in Python shell?
- Tkinter error: Couldn’t recognize data in image file
- Error: No module named ‘fcntl’
- How to use filter, map, and reduce in Python 3
- Praw & Discord.py: The bot keep sending the same meme. I want the bot to send different meme whenever it is asked
- How to uninstall a package installed with pip install –user
- Permanently add a directory to PYTHONPATH?
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- Using Python 3 in virtualenv
- Updating a dictionary in python
- Local variable referenced before assignment?
- ImportError: No module named ‘Tkinter’
- Can’t fix “zipimport.ZipImportError: can’t decompress data; zlib not available” when I type in “python3.6 get-pip.py”
- ‘method’ object is not subscriptable. Don’t know what’s wrong
- NameError: global name ‘xrange’ is not defined in Python 3
- Error: ” ‘dict’ object has no attribute ‘iteritems’ “
- What does “SyntaxError: Missing parentheses in call to ‘print'” mean in Python?
- How to upgrade pip3?
- TypeError: Missing 1 required positional argument: ‘self’
- What is __pycache__?
- SystemError: Parent module ” not loaded, cannot perform relative import
- How do I insert a JPEG image into a python Tkinter window?
- What is __pycache__?
- TypeError: can’t use a string pattern on a bytes-like object in re.findall()
- Tkinter scrollbar for frame
- matplotlib error – no module named tkinter
- Type error: cannot convert the series to
- What is the purpose of “pip install –user …”?
- How to remove punctuation marks from a string in Python 3.x using .translate()?
- Subplot for seaborn boxplot
- Infinite integer in Python
- enumerate() for dictionary in python
- Why Python 3.6.1 throws AttributeError: module ‘enum’ has no attribute ‘IntFlag’?
- How to use sys.exit() in Python
- Git Bash won’t run my python files?
- How to install xgboost in Anaconda Python (Windows platform)?
- installing urllib in Python3.6
- What is sys.maxint in Python 3?
- No Module Named ‘_pywrap_tensorflow_internal’
- Python: can’t assign to literal
- “Initializing” variables in python?
- Difference between except: and except Exception as e:
- How to install pytorch in windows?
- “Unicode Error “unicodeescape” codec can’t decode bytes… Cannot open text files in Python 3
- How to downgrade python from 3.7 to 3.6
- How to use an image for the background in tkinter?
- How to return dictionary keys as a list in Python?
- How to save a dictionary to a file?
- How to stop Python closing immediately when executed in Microsoft Windows
- Function to close the window in Tkinter
- How to downgrade the installed version of ‘pip’ on windows?
- Youtube_dl : ERROR : YouTube said: Unable to extract video data
- Using Look Up Tables in Python
- ImportError: No module named ‘cv2’ Python3
- Django Rest Framework — no module named rest_framework
- Unsupported operation :not writeable python
- Object of type ‘map’ has no len() in Python 3
- How do I run pip on python for windows?
- How to get the text cursor position in Windows?
- how to exit a python script in an if statement
- How to fix ‘RuntimeWarning: divide by zero encountered in double_scalars’
- Not able to pip install pickle in python 3.6
- Using unicode character u201c
- Decode Hex String in Python 3
- ImportError: cannot import name NUMPY_MKL
- built-in range or numpy.arange: which is more efficient?
- Disable / Enable Button in TKinter
- Printing subscript in python
- Why do I get this error “TypeError: ‘method’ object is not iterable”?
- Open File in Another Directory (Python)
- Python official installer missing python27.dll
- TypeError: ‘range’ object does not support item assignment
- tkinter gui layout using frames and grid
- install csv package in pycharm
- dump() missing 1 required positional argument: ‘fp’ in python json
- Meaning of list[-1] in Python
- TypeError: module.__init__() takes at most 2 arguments (3 given)
- How to install Openpyxl with pip
- Python cant convert ‘list’ object to str error [closed]
- Getting a name error when trying to input a string [duplicate]
- Generate a random letter in Python
- What’s the correct way to convert bytes to a hex string in Python 3?
- During handling of the above exception, another exception occurred
- Strange Exception in Tkinter callback
- ‘module’ has no attribute ‘urlencode’
- Anaconda “failed to create process”
- Python-3.2 coroutine: AttributeError: ‘generator’ object has no attribute ‘next’
- How to install PyQt4 on Windows using pip?
- How to install PyQt4 on Windows using pip?
- Python – difference between two strings