# FileNotFoundError: \[Errno 2\] No such file or directory

**URL:** https://discourse.jupyter.org/t/filenotfounderror-errno-2-no-such-file-or-directory/28484
**Category:** JupyterHub
**Tags:** help-wanted
**Created:** [September 18, 2024, 9:36pm UTC](https://discourse.jupyter.org/t/filenotfounderror-errno-2-no-such-file-or-directory/28484 "2024-09-18T21:36:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jchristian256](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@jchristian256](https://discourse.jupyter.org/u/jchristian256)
#### Post date: [September 18, 2024, 9:36pm UTC](https://discourse.jupyter.org/t/filenotfounderror-errno-2-no-such-file-or-directory/28484/1 "2024-09-18T21:36:04Z")

</div>

Having some issues. The first assignment went fine files were located in the directory and now I the notebook cant locate anything. Any assistance would be greatly appreciated.  
import pandas as pd  
import numpy as np  
import matplotlib.pyplot as plt

## data = pd.read\_csv(“C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 2\Homework\expenditure.csv”) data

FileNotFoundError Traceback (most recent call last)  
Cell In[10], line 1  
----\> 1 data = pd.read\_csv(“C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 2\Homework\expenditure.csv”)  
2 data

File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/parsers/readers.py:912, in read\_csv(filepath\_or\_buffer, sep, delimiter, header, names, index\_col, usecols, dtype, engine, converters, true\_values, false\_values, skipinitialspace, skiprows, skipfooter, nrows, na\_values, keep\_default\_na, na\_filter, verbose, skip\_blank\_lines, parse\_dates, infer\_datetime\_format, keep\_date\_col, date\_parser, date\_format, dayfirst, cache\_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding\_errors, dialect, on\_bad\_lines, delim\_whitespace, low\_memory, memory\_map, float\_precision, storage\_options, dtype\_backend)  
899 kwds\_defaults = \_refine\_defaults\_read(  
900 dialect,  
901 delimiter,  
(…)  
908 dtype\_backend=dtype\_backend,  
909 )  
910 kwds.update(kwds\_defaults)  
 → 912 return \_read(filepath\_or\_buffer, kwds)

File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/parsers/readers.py:577, in \_read(filepath\_or\_buffer, kwds)  
574 \_validate\_names(kwds.get(“names”, None))  
576 # Create the parser.  
 → 577 parser = TextFileReader(filepath\_or\_buffer, \*\*kwds)  
579 if chunksize or iterator:  
580 return parser

File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1407, in TextFileReader. **init** (self, f, engine, \*\*kwds)  
1404 self.options[“has\_index\_names”] = kwds[“has\_index\_names”]  
1406 self.handles: IOHandles | None = None  
 → 1407 self.\_engine = self.\_make\_engine(f, self.engine)

File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/parsers/readers.py:1661, in TextFileReader.\_make\_engine(self, f, engine)  
1659 if “b” not in mode:  
1660 mode += “b”  
 → 1661 self.handles = get\_handle(  
1662 f,  
1663 mode,  
1664 encoding=self.options.get(“encoding”, None),  
1665 compression=self.options.get(“compression”, None),  
1666 memory\_map=self.options.get(“memory\_map”, False),  
1667 is\_text=is\_text,  
1668 errors=self.options.get(“encoding\_errors”, “strict”),  
1669 storage\_options=self.options.get(“storage\_options”, None),  
1670 )  
1671 assert self.handles is not None  
1672 f = self.handles.handle

File /opt/conda/envs/anaconda-panel-2023.05-py310/lib/python3.11/site-packages/pandas/io/common.py:859, in get\_handle(path\_or\_buf, mode, encoding, compression, memory\_map, is\_text, errors, storage\_options)  
854 elif isinstance(handle, str):  
855 # Check whether the filename is to be opened in binary mode.  
856 # Binary mode does not support ‘encoding’ and ‘newline’.  
857 if ioargs.encoding and “b” not in ioargs.mode:  
858 # Encoding  
 → 859 handle = open(  
860 handle,  
861 ioargs.mode,  
862 encoding=ioargs.encoding,  
863 errors=errors,  
864 newline=“”,  
865 )  
866 else:  
867 # Binary mode  
868 handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 2\Homework\expenditure.csv’

os.getcwd()  
‘/home/1a28dd95-e8a8-48a4-9eb8-72516e955012’

## os.chdir(“C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 3\Homework\election2000.csv”)

FileNotFoundError Traceback (most recent call last)  
Cell In[17], line 1  
----\> 1 os.chdir(“C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 3\Homework\election2000.csv”)

FileNotFoundError: [Errno 2] No such file or directory: ‘C:\Users\ITman\OneDrive\Desktop\Data analytics school\MSC 550\Module 3\Homework\election2000.csv’

---

<div class="post-metadata">

### Author: ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)
#### Post date: [September 19, 2024, 2:25pm UTC](https://discourse.jupyter.org/t/filenotfounderror-errno-2-no-such-file-or-directory/28484/2 "2024-09-19T14:25:55Z")

</div>

Two things.  
This is probably not a Jupyter issue, and therefore not pertinent to this forum. There are a lot of ways to run Python and Jupyter is only one of them. I suspect the code involved would give you the same result if you ran it in the same environment in the terminal using a Python console or calling a script with the code in it via Python, the more traditional ways to run Python code.

Second, this looks like a misunderstanding about a file path/location.  
I note that OneDrive is involved and you are having path issues. There’s a lot out there already, even on this forum, about how OneDrive puts files where users don’t expect. Please research with that term in your searches and read [Getting good answers to your questions](https://discourse.jupyter.org/t/getting-good-answers-to-your-questions/1825) as guidance to posting here and to similar forums. I’d give a plug for the last link in that guide [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask), paying particular attention to the headings ‘Search, and research’, ‘ **Write a title that summarizes the specific problem** ’, and ‘Help others reproduce the problem’.  
You have tagged this under the ‘JupyterHub’ category. Is that the case? If that is true, you also wouldn’t be using local paths referring to places on your own machine. The JupyterHub would probably not have access to our local drive due to security issues as you are probably accessing the JupyterHub with a connection inside your browser?

* * *

Additional suggestion:

For pasting code in so it is readable in forums such as this, you’ll want to learn about ‘block code formatting’ [here](https://meta.discourse.org/t/post-code-or-preformatted-text/188910#block-code-formatting-6). (Or see about ‘fenced code blocks’ [here](https://meta.stackoverflow.com/a/251362/8508004). They are both the same thing if you look into the details. They just have slightly different terms used in the two locations.
