4

When I start up iPython in Ubuntu, I normally just run my script like this:

run code.py

If something fails, I can keep working with the variables and functions defined in the code. The problem starts when I fix the code using a text editor and try running it again. Then I get:

run code.py
File "<ipython-input-16-b1a3e2c6b7e8>", line 1
    run code.py
           ^

The ^ always marks the last character before the .py extension. If I close iPython and reopen it, I can run the code without a problem. This issue only arises when I run a second code from iPython, and the problem is solved by resetting iPython.

It gets very annoying and I can't figure out what is causing this.

4
  • Might be a character encoding issue? Or maybe the file can't be accessed because the previous run is still running? Commented Oct 29, 2018 at 1:57
  • The thing is this happens to me with different scripts, which led me to think there might be something wrong with iPython itself, but I haven't been able to figure it out. It may as well be something that is wrong in all my scripts, but if that were the case shouldn't the error report point to the line in the script that is causing the error? When I've had syntax errors inside the script they were always reported and located, and the fact that restarting iPython lets me run it again just confuses me more. Commented Oct 29, 2018 at 3:16
  • Have you searched their known bugs? (github.com/ipython/ipython/issues) Or submit yours there ofcourse Commented Oct 29, 2018 at 3:18
  • Ok, I'll have a look over there, thanks! Commented Oct 31, 2018 at 18:03

1 Answer 1

7

I've finally realized what was the problem. I was calling a variable "run" inside most of my scripts, and then ipython was left without the command run.

Sign up to request clarification or add additional context in comments.

1 Comment

Same here. Thanks for asking and answering this question - it saved me a lot of time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.