FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles (/thread-33934.html) Pages:
1
2
|
FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 I make directory and sub directory in the same project to train and fit my model still get an error FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles.csv' Quote: X = pd.read_csv("model/doc2vec.model/Articles.csv", index_col='id') X.head() Quote:Overall errors
RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Gribouillis - Jun-11-2021 With a relative path, Python looks for the file relatively to the current working directory of the current process. Is it the same as the directory containing the 'model' directory ? RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - snippsat - Jun-11-2021 On Windows as you use most give absolute path. Example if Articles.csv is in that folder on D:\ drive.X = pd.read_csv("D:/model/doc2vec.model/Articles.csv", index_col='id')The other option is to have Articles.csv in same folder as similarity.py then you give no path.X = pd.read_csv("Articles.csv", index_col='id') RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Gribouillis - Jun-11-2021 You can also give more complex paths relative to the python file's directory from pathlib import Path thisdir = Path(__file__).parent csv = thisdir/'..'/'..'/'spam'/'Articles.csv' RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 @Gribouillis yeah thanks but complex path is not seen good RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 (Jun-11-2021, 02:24 PM)snippsat Wrote: On Windows as you use most give absolute path. @snippsat thanks yeah i check where the exact problem RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 @Gribouillis yeah thanks but complex path is not seen good RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 after apply the abs path it return another error X = pd.read_csv("D:\Clustering\text-cluster-master\text-cluster-master", index_col='id') X.head()
RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - snippsat - Jun-11-2021 You can not do it like this and singel \ will mess up path because of escape character.# \t is Tab,see the space so path will never work like this >>> s = 'D:\text-cluster-master' >>> print(s) D: ext-cluster-masterYou most also point to the exacts placement of the file and the folder. # Turn backslash this X = pd.read_csv("D:/Clustering/text-cluster-master/text-cluster-master/Articles.csv", index_col='id') # Or use raw string X = pd.read_csv(r"D:\Clustering\text-cluster-master\text-cluster-master\Articles.csv", index_col='id') RE: FileNotFoundError: [Errno 2] No such file or directory: 'model/doc2vec.model/Articles - Anldra12 - Jun-11-2021 @snippsat yeah you are right still i have same error |