Menu
The Jupyter Notebook. The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.
I'm new and studying machine learning. I stumble upon a tutorial I found online and I'd like to make the program work so I'll get a better understanding. However, I'm getting problems about loading the CSV File into the Jupyter Notebook.
I get this error:
and here is the code:
I followed tutorials online regarding this error but none worked. Does anyone know how to fix it?
3rd attempt with r'path'
I've tried also ' and utf-8 but none worked.
I'm using the latest version of AnacondaWindows 7Python 3.7
stella
stellastella
4 Answers
Use raw string notation for your Windows path. In python ' have meaning in python. Try instead do string like this r'path':
student_data = pd.read_csv(r'C:UsersxxxxDesktopstudent-intervention- systemstudent-data.csv')
If it doesnt work try this way:
Bohun MieleckiBohun Mielecki
Either replace all backslashes
with frontslashes /
or place a r
before your filepath string to avoid this error. It is not a matter of your folder name being too long.
As Bohun Mielecki mentioned, the
character which is typically used to denote file structure in Windows has a different function when written within a string.From Python3 Documentation: The backslash
character is used to escape characters that otherwise have a special meaning, such as newline, backslash itself, or the quote character.How this particularly affects your statement is that in the line
Users
matches the escape sequence Uxxxxxxxx
whereby xxxxxxxx
refers to a Character with 32-bit hex value xxxxxxxx
. Because of this, Python tries to find a 32-bit hex value. However as the -sers
from Users
doesn't match the xxxxxxxx
format, you get the error:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated UXXXXXXXX escape
The reason why your code works now is that you have placed a
r
in front of 'C:UsersxxxxDesktopprojectstudent-data.csv'
. This tells python not to process the backslash character /
as it usually does and read the whole string as-is. I hope this helps you better understand your problem. If you need any more clarification, do let me know.
Source: Python 3 Documentation
MoltenMuffinsMoltenMuffins
baldermanbalderman2,56511 gold badge1414 silver badges2222 bronze badges
I found the problem. The problem is my folder name that is really long. I changed my folder name into 'project' and the data is now finally loaded! Silly!
stellastella
Not the answer you're looking for? Browse other questions tagged pythonpython-3.xjupyter-notebook or ask your own question.
I've been running a script on jupyter notebooks for about 26 hour; I haven't really been using my computer for anything else, but it needs to run this program that will take ~30 hours to complete. At about 21 hours in, it stopped saving and my terminal had this:
where [file.ipynb] is the location of my jupyter notebook. It also says:
in the top right part of the notebook again. The program is still running and I don't want to restart jupyter notebook and have to run the program again, as I have a deadline, is there anything else I can do?
I'm using google chrome, but I don't have the LastPass extension or any '%' characters in my code, as another post suggested.
Thanks for any help!
V PV P
4 Answers
Sorry this probably comes late as far as your deadline is concerned... The easiest way I found is this:
Just open another notebook on the same kernel, and the issue is magically gone; you can again save the notebooks that were previously showing the
_xsrf
error.caxcaxcoatlcaxcaxcoatl
I use jupyter notebooks daily and had never experienced this issue before... until today. I had the notebook open all day but it wasn't running anything and then for no apparent reason stopped auto-saving with the
'_xsrf' argument missing from POST
error message in the top right. FYI - this is a python3 notebook.I don't know the cause of this problem but I have recently upgraded my python3 version to 3.7.2 and upgraded all of my site-packages to their latest version as of a few days ago which could possibly be the cause.
As for a solution, as suggested in the comment by @AlexK, I opened the same notebook in a new window (different browser in fact), using
in the terminal to get the URL with login token.
This resulted in me having the notebook open and savable again but the information I had entered since the last successful auto-save was missing. Thankfully, my broken instance was still open and working apart from saving so I was able to simply copy and paste the information across then hit save. So, keep the broken instance open if you try this!
BiggsyBiggsy
When I click 'save' button, it has this error. Based on the answers in this post and other websites, I just found the solution.My jupyter notebook is installed from pip. So I access it by typing 'jupyter notebook' in the windows command line.
(1) open a new command window, then open a new jupyter notebook. try to save again in the old notebook, this time ,the error is 'fail: forbidden'
(2) Then in the old notebook, click 'download as', it will pop out a new windows ask you the token.
(3) open another command window, then open another jupyter notebook, type 'jupyter notebook list'copy the code after 'token=' and before :: to the box you just saw. You can save this time. If it fails, you can try another token in the list
Richard LiangRichard Liang
I got the same problem (impossible to save either notebooks and .py modules) using an image in the nvidia docker. The solution was just opening a terminal inside jupyter without typing anything but exit once the files were saved. It was done in the same browser/jupyter instance.
Machine OS: Ubuntu 18.04
brzbrz