piggs_boson
piggs_boson

Reputation: 1007

Ctrl+C in terminal producing python traceback, on trying an invalid command

I entered an invalid command, d into my linux terminal. It usually takes around 1 second before it would print d: command not found. Today, I hit Ctrl+C before it could print 'command not found', and got the following output:

user@mypc:~/$ d
^C
user@mypc:~/$ Failed to import the site module
Traceback (most recent call last):
  File "/usr/lib/python3.4/site.py", line 586, in <module>
    main()
  File "/usr/lib/python3.4/site.py", line 573, in main
    known_paths = addsitepackages(known_paths)
  File "/usr/lib/python3.4/site.py", line 358, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "/usr/lib/python3.4/site.py", line 212, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "/usr/lib/python3.4/site.py", line 164, in addpackage
    f = open(fullname, "r")
KeyboardInterrupt

user@mypc:~/$

Why did this happen?

Edit: here is the output of the which command:

$ which xyx
$
$ which d
$

Upvotes: 1

Views: 238

Answers (2)

repzero
repzero

Reputation: 8412

It could be that when you hit the keyboard interrupt key, python did not not reach that part of your program that subsitute "d" into a particular set of codes that would usually generate this error. So you didn't have the error "d: command not found" and also another part of your codes that also takes 'd' before it reaches the codes that gives d: command not found is now giving an error since 'd' is not a number.

However, based on the info...It simply appears that your program was interrupted when python was invoking one of its module and as a result you have an error message since this process wasn't completed.

Upvotes: 0

tripleee
tripleee

Reputation: 189417

Ubuntu includes a "command not found" handler in their Bash setup, which is written in Python. I guess you interrupted that.

One second sounds like a long time. Is your system very old, or under heavy load?

Upvotes: 2

Related Questions