Python Forum
OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! - 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: OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! (/thread-10874.html)



OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! - meganhollie - Jun-11-2018

Hi - I'm going to preface this by saying that I have VERY little coding experience, and am cobbling a topic modeling program for a paper I'm writing. I successfully ran the code last week, with no errors. I tried to run it again today and I'm getting the following:


file_content = open("nippur-input.txt").read()
tokens = nltk.word_tokenize(file_content)
print (tokens)
OSError Traceback (most recent call last)
<ipython-input-2-5dd1937bcad9> in <module>()
1 #tokenize
----> 2 file_content = open("nippur-input.txt").read()
3 tokens = nltk.word_tokenize(file_content)
4 print (tokens)

OSError: [Errno 22] Invalid argument

Any ideas on how I should fix this?
If I remove the "" I get :
NameError: name 'nippur' is not defined

I'm sorry if I'm not providing enough information!

ETA: I run a macOS, and I use python through a jupyter notebook, if that is relevant.


RE: OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! - Larz60+ - Jun-11-2018

Ok,

you are not showing enough code
do you have import nltk ?
There must be more than these three lines.
It is always helpful, (and requested) that snippets of code be complete enough to run.
Quote:ETA: I run a macOS, and I use python through a jupyter notebook, if that is relevant.
possibly, since in jupyter the last time you ran, you may have executed portions of code that you missed this time.
Try clicking the >| run button which will execute all code in sequence.


RE: OSError: [Errno 22] Invalid argument - wasn't there last time I ran the code! - meganhollie - Jun-11-2018

Thank you - I went back and checked the input file and it had corrupted. I switched it out and it's working now.
I will post all of the code next time, thank you!