dictation-toolbox / Caster

Dragonfly-Based Voice Programming and Accessibility Toolkit
https://dictation-toolbox.github.io/Caster/
Other
340 stars 121 forks source link

Upgrade to Python 3 #907

Closed slatesky284 closed 3 years ago

slatesky284 commented 3 years ago

Hi I'd like to request updating Caster to use Python 3. The Caster install doc says:

Download and install Python v2.7.18 32-bit listed as Windows x86 MSI installer not Python 3 or the Python 2.7 64-bit. These dependencies will change when Natlink utilizes Python 3.

It appears that Natlink has already updated to use Python 3. The Natlink install doc says:

Install a Python 3.8 32 bit on your system, and select install for all users.

I have some other programs I'd like to use that require Python 3 and are incompatible with having Python 2 installed on the same machine. Some people claim you can install them side by side, but I'm not able to do that.

What else is needed to support python 3?

LexiconCode commented 3 years ago

What else is needed to support python 3?

Caster has had support for Python 3 for a long time. In fact all other engines utilize Python 3 64-bit. I've been utilizing natlink with Python 3-32 bit for some time. However it wasn't until the last few days ago that some major bugs were fixed and released in a way that was easy for people to install.

As you have noticed a PIP package has been published. However they have not made an official release as there is still some cleaning up to do. I would like to give it a week or so before I actually publish documentation supporting Python 3 for Dragon. During that time I'm working with people in the Dictation Toolbox community to test natlink. We've already found a few bugs but nothing that's a showstopper yet. All that is to say you're welcome to give the try and definitely let me know if you run into anything.

Preinstall requirements

Natlink Install Instructions

  1. close Dragon
  2. open cmd/power shell as administrator
  3. pip install natlink
  4. natlinkconfig_cli # should auto setup and register itself.
  5. type 'n C:\Backup\Library\Documents\Caster' to set the natlink user directory. Modify to wherever
  6. restart Dragon

Manually register or enable

  1. type 'u' for to see commandline options
  2. type 'r' to register natlink
  3. type 'e' - enable/disable Natlink

Best luck to all and I hope this helps!

slatesky284 commented 3 years ago

@LexiconCode thanks so much for improving the installation! The pip package will make it so much easier. I tested those instructions and I ran into a problem getting natlink to recognize my user directory. I was able to successfully get natlink running (I think).

C:\Python38-32\Scripts>natlinkconfig_cli.exe
Natlink.dll can not be imported in natlinkstatus
pyd path "c:\python38-32\lib\site-packages\natlinkcore\natlink.pyd" does not exist...
no natlink.pyd, clear "NatlinkPydOrigin" setting
copied pyd (=dll) file c:\python38-32\lib\site-packages\natlinkcore\PYD\natlink_3.8_Ver15.pyd to c:\python38-32\lib\site-packages\natlinkcore\natlink.pyd
registered "c:\python38-32\lib\site-packages\natlinkcore\natlink.pyd"
registered "c:\python38-32\lib\site-packages\natlinkcore\natlink.pyd"
Natlink is enabled, you can now restart Dragon

Config Natlink> n C:\Users\User\Nextcloud\Software\Dragon\Caster-master
Setting the UserDirectory of Natlink to C:\Users\User\Nextcloud\Software\Dragon\Caster-master

Config Natlink> q

However, when I start dragon with natlink it says "no UserDirectory specified". Also, the caster commands are not working.

Displaying Python Environment
Warning:
originalPyd setting is missing in natlinkstatus.ini

Warning:
originalPyd setting is missing in natlinkstatus.ini

Cannot find UnimacroDirectory, return ""
Vocola is not installed, no VocolaDirectory
Instructions for attaching a python debugger are in C:\Python38-32\lib\site-packages\natlinkcore\debugging python instructions.docx 
--
-- natlinkmain starting...
Vocola is disabled
Unimacro is disabled
no UserDirectory specified
currentUser at start of Natlink: ('user', 'C:\\ProgramData\\Nuance\\NaturallySpeaking15\\Users\\User\\current')
changeCallback, Type: user, args: ('user', 'C:\\ProgramData\\Nuance\\NaturallySpeaking15\\Users\\User\\current')
setUserInfo, setting language to: enx
no path given for AhkUserDir: ""
natlinkmain started from C:\Python38-32\Lib\site-packages\natlinkcore:
  Natlink version: 5.0.0
  DNS version: 15
  Python version: 38
  Windows Version: 10
----------------------------------------
==============================
natlinkstatus reported the following warnings:

originalPyd setting is missing in natlinkstatus.ini
==============================

It seems that the natlinkconfig_cli program thinks it set the user directory, but natlink in dragon does not recognize it.

Config Natlink> i
natlinkstatus.getLanguage, Dragon not active, return "enx"
Cannot find UnimacroDirectory, return ""
Vocola is not installed, no VocolaDirectory
---Natlink is enabled
        NatlinkDirectory        c:\python38-32\lib\site-packages\natlinkcore
        InstallVersion  5.0.0
---Vocola is disabled
---Unimacro is disabled
---User defined grammars are enabled
        UserDirectory   C:\Users\User\Nextcloud\Software\Dragon\Caster-master

Thinking I made a mistake I tried it again (and rebooted for good measure). I disabled natlink, enabled it and then registered it. If I register a second time then it prints the below error. It also seems to delete the registry key I added at Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Python\PythonCore\3.8-32\PythonPath\Natlink. I added the registry key back and I get the same error above about a missing user directory.

C:\Python38-32\Scripts>natlinkconfig_cli.exe

Config Natlink> r
do action: (Re) register and enable natlink.pyd
natlinkconfigfunctions failed because of fatal error:

cannot remove natlink.pyd from the core directory: c:\python38-32\lib\site-packages\natlinkcore
Probably Dragon is running

So if Dragon is running, close it.

Then try, if you choose to do so, to Re-register Natlink with this program
(option "r" in the CLI, Command Line Interface).

*** See also the messageBox, and close it

Config Natlink> q

Any ideas on what might be going on?

LexiconCode commented 3 years ago

Try removing via command line running administrator rm c:\python38-32\lib\site-packages\natlinkcore\natlink.pyd Might uninstall and reinstall natlink. pip uninstall natlink

Cannot remove natlink.pyd from the core directory: c:\python38-32\lib\site-packages\natlinkcore
Probably Dragon is running

Weird it didn't provide the complete complete path to natlink.pyd as it's not shown above. Fortunately the registry has nothing to do with the user directory. If I'm correct the registry is only used to register where natlink.pyd is located.

Let's get the above error message straightened out and then we can try again for the user directory. A new version of the pip package that doesn't rely on the registry should be out in in the near future.

slatesky284 commented 3 years ago

Quitting the natlinkconfig_cli program allows me to delete natlink.pyd without admin permissions. Next time I start the program it registers successfully. Perhaps it keeps an open file handle while it is running? You can test it by running r twice in a row.

I uninstalled natlink 5.0.0 and installed it again with version 5.1.1. I get the same message in the natlink window saying "no UserDirectory specified".

LexiconCode commented 3 years ago

@slatesky284 Based on what you're experiencing have opened up a new issue on the Natlink repository. Let's migrate the discussion and troubleshooting to that issue.

LexiconCode commented 3 years ago

@slatesky284 can you verify one more time trying to set the user directory.

  1. N - to clear the user directory
  2. 'n C:\Backup\Library\Documents\Caster' to set the natlink user directory. Modify as needed
slatesky284 commented 3 years ago

Yep I did that step already. Same result.

c:\Python38-32\Scripts>natlinkconfig_cli.exe

Config Natlink> n
also enter a valid folder

Config Natlink> n C:\Users\User\Downloads\Caster-master\Caster-master
Setting the UserDirectory of Natlink to C:\Users\User\Downloads\Caster-master\Caster-master

Config Natlink> q
LexiconCode commented 3 years ago

Yep I did that step already. Same result.

Redo what you did above. without quitting do the following:

  1. type "i"
  2. type "I"

then paste output here.

Next if the above the output includes the user directory quit this CLI and launch it again just do

  1. type "i"
  2. type "I"

This helps me gauge when the user directory disappears.

LexiconCode commented 3 years ago

Issue is resolved see Nalink issue.