Directory:
The preface explains in detail
preface
Go to WeChat and put on a fun application reinforcement learning. But go on the run and come across the problem before you go:
FileNotFoundError: [Errno 2] No such file or directory: ‘objects/ ingfix.pkl
has to learn and come up with a solution:
explain
There is no folder or file, that is, you have access to a file that does not exist, but in fact, if the file you are accessing does not exist, the method w is used to cut access, it will create a new document, so the main problem is, there is no folder, just create a new one.
Explain in detail
Python, the OS library, is required to read and write files. Due to open the way to your files is “w”, namely file does not exist when they create a file, so the PKL documents (I mean the relative path of the PKL) does not exist is automatically created, this is not the problem, the problem is the relative path, that is the path exists, this folder does not exist as a problem. So we have to determine if this path exists. Create if it doesn’t exist.
import os
if not os.path.exists(path):
os.mkdir(path)
Also, note that you can only create one layer at a time for paths, meaning that the layer above your Objects exists, or you will still get an error.
Read More:
- [Solved] Python project runs the open() function error: FileNotFoundError: [Errno 2] No such file or directory
- No code, a solution to the error in the path of reading CSV file by Python: filenotfounderror: [errno 2] no such file or directory: ‘XX. CSV‘
- FileNotFoundError: [Errno 2] No such file or directory: ‘./mnist_image_label/mnist_train_jpg_6000028
- [Solved] Mac ffmpeg Install Error: filenotfounderror: [errno 2] no such file or directory: ‘ffmpeg’: ‘ffmpeg’
- When Python Django creates a database, can’t open file ‘ manage.py ‘: [Errno 2] No such file or directory
- The solution of no such file or directory and cannot load native module running error of python3 pyinstaller after packaging
- fatal error: Python.h: No such file or directory
- fatal error: Python.h: No such file or directory compilation terminated.
- Python environment error, bad interpreter: there is no file or directory
- fatal error: Python.h: No such file or directory
- Fatal error in CentOS: Python. H: no that file or directory
- Error occurred when Python installed the pocketsphinx module (package): Command‘ swig.exe “Failed: no such file or directory
- When python installs pocketsphinx module (package), an error is reported: command ‘swig.exe’ failed: No such file or directory
- No such file or directory
- Solve syntax error: unexpected end of file or /bin/bash^m: bad interpeneter: no match file or directory
- Cannot open include file: ‘io.h‘: No such file or directory
- Install Python C extension compiler environment under windows (solve “error: command” cl.exe ‘ failed: No such file or directory”)
- Install python’s C extension compilation environment under windows (solve “error: command’cl.exe’ failed: No such file or directory”)
- #During OpenGL development, fatal error C1083: can’t open include file: “GL / glut. H”: no such file or directory
- In VS2010, the compiler cannot open the file “GL / glaux. H”: no such file or directory