Author Topic: ValueError: bad key  (Read 5354 times)

0 Members and 1 Guest are viewing this topic.

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
ValueError: bad key
« on: March 23, 2010, 15:21 »
Hello! I just went through tutorial, to step 8 of Chapter 6 (drag and drop biphenyl script icon from your file system browser into the Job Manager tool), and ooops...  :o :'(
Code
Running: C:\Program Files\QuantumWise\Virtual NanoLab 2008.10.0\atk\bin\atk.exe c:/users/1/appdata/local/temp/tmprhmejo.nl
VkKeyScan("d") = -1
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File ".\ATK\CLI\__init__.py", line 30, in ?
  File "lib\IPython\__init__.py", line 52, in ?
  File "lib\IPython\genutils.py", line 117, in ?
  File "lib\readline.py", line 9, in ?
  File "lib\pyreadline\init_rl.py", line 3, in ?
  File "lib\pyreadline\rlmain.py", line 62, in __init__
  File "lib\pyreadline\rlmain.py", line 1137, in emacs_editing_mode
  File "lib\pyreadline\rlmain.py", line 1130, in _bind_exit_key
  File "lib\pyreadline\keysyms.py", line 111, in key_text_to_keyinfo
  File "lib\pyreadline\keysyms.py", line 151, in keyname_to_keyinfo
  File "lib\pyreadline\keysyms.py", line 119, in char_to_keyinfo
ValueError: bad key
Terminated Abnormally
What can I do?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #1 on: March 23, 2010, 17:00 »
Hmm, why does it look like it's trying to run ATK interactively...?

Do you have another Python installation, and perhaps IPython too, which might have left some configuration files in your home directory?

Just for safety, also attach the script you tried to run.

Can you run the script from the command line directly? I.e. "atk script.py"?

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
Re: ValueError: bad key
« Reply #2 on: March 24, 2010, 07:23 »
I attach my script below. Exactly the same output I get with any other script - e.g. from samples folder. There is no other Python-based software as far as I know. PC works under Windows 7 (if this matters). Running script from command line leads to splash and disappear of black screen with a few text. Running script with ATK 2010 shell leads to:
Code
+ -------------------------------------------------------------
| NanoLanguageScript execution started
+ -------------------------------------------------------------
Traceback (most recent call last):
  File "c:\users\1\appdata\local\temp\2737964686931724.py", line 1, in <module>
    from ATK.KohnSham import *
ImportError: No module named ATK.KohnSham
Exception in thread Thread-1 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
  File ".\build\vnl\lib\threading.py", line 522, in __bootstrap_inner
  File ".\build\vnl\lib\threading.py", line 477, in run
  File ".\zipdir\NL\__init__.py", line 376, in monitorFunction
<type 'exceptions.TypeError'>: 'NoneType' object is not callable
NanoLanguageScript execution failure
+ -------------------------------------------------------------
| NanoLanguageScript execution finished
+ -------------------------------------------------------------

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #3 on: March 24, 2010, 07:59 »
The scripts are not compatible between 2008 and 2010, unfortunately, so it's clear why it doesn't work to run it with 2010.02. (Although, the change needed are small, at least for the geometric configuration.) The 2008.10 errors are weird, but I don't understand the splash screen thing. ATK will not raise a splash screen (VNL will). So, if you run, in a terminal,
Code
atk molecule_configuration_script.py
there should be no splash, and hopefully no error messages. Fingers crossed! If not, and anyway, the version for the future is 2010.xx, so as long as that works, all is ok. So, to convert the script to 2010.xx: 1) Change from import ATK.KohnSham * to from NanoLanguage import * in the import statement on line 1 2) Remove the line from ATK.MPI import * (line 2) 3) Remove the whole if processIsMaster(): part (lines 4-8) 4) Remove line 11 5) Remove all lines after the geometry definition (the lines with MoleculeConfiguration) (lines 47 to the end) For your convenience, I have attached the resulting file (while the above instructions are general for all users looking to convert their 2008 molecules to 2010). Now open VNL 2010.02 and drop the structure on the Scripter to set up the calculation.

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
Re: ValueError: bad key
« Reply #4 on: March 24, 2010, 11:38 »
Attached is result of running in terminal. I had incorrectly called it "splash screen", so do not be confused with it.

Modified scripts work correctly with 2010 Scripter and Job Manager.

Will I loose a lot of functionality with unworking 2008?


Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #5 on: March 24, 2010, 16:28 »
By summer, 2010 will have (almost) the same functionality as 2008, but right now there's a slight difference, I admit. These are unusual errors, I have never seen anything like this before. Taking a peek at your email, I surmise that you are using a Russian keyboard. Google turns up a few hits on this, all related to foreign keyboards and readline. So let's try a few things. Before running, in the terminal, switch to US keyboard (in Window, not hardware!). Also, try to run some minimal scripts, like
Code
print "hello"
and then
Code
from ATK.KohnSham import *
print "hello"

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
Re: ValueError: bad key
« Reply #6 on: March 25, 2010, 17:41 »
Both scripts lead to trhe same result - please look at attached screenshot.
Keyboard was shifted to English.

Some thoughts:

On my PC atk\bin folder of 2008 version is read-only and I can copy script to there only with administrator rights.. But this is the same for 2010 bin folder, which works.

I have set up licenses for 2008 and 2010 programs in different way - one by pointingto license file, another by setting system values manually (I don't remember exactly for what one). May this relate to problem?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #7 on: March 25, 2010, 18:12 »
Does you username on this machine contain non-Latin characters?

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
Re: ValueError: bad key
« Reply #8 on: March 27, 2010, 11:58 »
No, username is just a number "1"

2010 use the folder C:\Users\1 without troubles. Commands like  "nlpython script.py" in this folder are executed correctly.


Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #9 on: March 28, 2010, 02:19 »
The problem has been reported before - once: http://www.mail-archive.com/python-list@python.org/msg18218.html
and it's quite clear it must be related to the keyboard layout. It's kind of a bug, I guess, in the readline library, but not an obvious one.

The fact that ATK 2010 works better than 2008 is probably because 2010 doesn't have readline yet. I don't know if they issue has been solved in readline, or we will see this pop up once we implement readline in 2010...

Now the user who posted the issue, Michele Simonato, couldn't solve it by switching to an English keyboard layout. In fact, his solution was to patch readline: http://www.mail-archive.com/python-list@python.org/msg18348.html

At first glance it would appear that you don't have that luxury in ATK since it's already compiled. However, it's actually quite easy to patch individual libraries. My solution is slightly different from Michele's, and perhaps a bit aggressive, but simpler:

1) Download pyreadline 1.3 from http://ipython.scipy.org/dist/old/pyreadline/

2) Extract the tar file

3) Open the file keysyms.py, found in the subdirectory pyreadline, in an editor

4) Comment out line 119 (i.e. add a # at the beginning of the line) which contains the instruction to "raise ValueError".

5) Now copy this file to C:\Program Files (x86)\QuantumWise\ATK 2008.10\lib\pyreadline and C:\Program Files (x86)\QuantumWise\Virtual NanoLab 2008.10.0\atk\lib\pyreadline (without (x86) if using WinXP).

6) Make a backup copy of the file keysyms.pyc in both of these directories.

7) Run your ATK script again.

Now, I cannot guarantee that this works, but it's definitely worth a try! I also cannot guarantee it doesn't mess up iPython and readline, but this is less of an issue unless you are planning to use ATK interactively.

If my solution results in a lot of strange text written to the screen (arising from line 118 in keysyms.py) you can replace that line by a "pass" command (you cannot just remove it, or rather then you have to remove line 117 too). Or try Michele's solution (after line 116).

Let me know if it works, or if you need more help (more detailed instructions perhaps).

Good luck!

Offline MNTC1

  • Regular QuantumATK user
  • **
  • Posts: 6
  • Reputation: 0
    • View Profile
Re: ValueError: bad key
« Reply #10 on: March 29, 2010, 12:50 »
Yes, your solution works!

I went through algorithm, got normal script execution with "a lot of strange text", replaced line 118 and now all works OK.

Thank you!

But I copied keysms.py to only one location. Second folder: "C:\Program Files (x86)\QuantumWise\ATK 2008.10" is absent in my installation.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: ValueError: bad key
« Reply #11 on: March 30, 2010, 08:24 »
Glad it worked - this was one of the harder problems to solve!

If you didn't install ATK as a separate package (and you don't need to), right, then you only need to copy it to one place.