[1.1.4] PyCharm: running a script: getBundleFolder() seems to return None

Asked by matteoa

hello all,
I've been using Sikulix via PyCharm for months for debug, running from it etc etc etc, no problem, a pleasure to use.

This morning I updated sikulix+API with latest version and when I try to run the project that was running before I have this error message:

Traceback (most recent call last):
  File "MYPerfectlyWorkingScript.py", line 75, in <module>
    Debug.setUserLogFile(b + 'logs\\' + str(strLogName))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Picked up _JAVA_OPTIONS: -Xmx1024M

Process finished with exit code -1
this is the piece of code executed at the very beginning of the script:
b=getBundleFolder()
strLogName=datetime.now().strftime('%Y%m%d_%H%M%S'+ "-DbgSiK.log")
Debug.setUserLogFile(b + 'logs\\' + str(strLogName))

Any idea about what gone wrong?

In the meantime I did nothing with the project but I can remind that there were an automatic update of the JVM.
Thanks for any help
Matteo

this is my Sikulix configuration:
1.1.4-SNAPSHOT-#378-2019-09-05_08:05/Windows10.0/Java8(64)1.8.0_221-b27
and this is the PyCharm one:
PyCharm 2018.2.4 (Community Edition)
Build #PC-182.4505.26, built on September 19, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

check your Jython setup in PyCharm: 1.1.4 uses Jython 2.7.1

BTW: IMHO this should be sufficient:
Debug.setUserLogFile(b + 'logs\\' + strLogName)

b=getBundleFolder()
works in the IDE but returns None if no bundlePath is defined.
This might be a problem with 1.1.4, when you run a .py file in PyCharm without the run support of 1.1.4.

I have to check.

Revision history for this message
matteoa (matteoa) said :
#2

hello RaiMan,
I installed Jython 2.7.1 but at the time of setting it up with Pycharm as project interpreter having selected
c:\jython2.7.1\bin\jython.exe
It shows me an error that I'm not expert enough in Python nor in PyCharm to solve:
executed command:
C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\packaging_tool.py untar
C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.4\helpers\virtualenv-16.0.0.tar.gz
error occurred:
Non-zero exit code (-1)
command output:
Error loading Python DLL: C:\jython2.7.1\bin\python27.dll (error code 14001)

I retried this today but I remember I did that a lot of time ago with the same result...so I used (only for for Pycharm) 2.7.0...while using the standalone version for Sikulix...a little a mess, I know, but until today it was working...
I tried also to use the standalone version of the
Thanks a lot for your support, superprompt as usual!!
Matteo

Revision history for this message
matteoa (matteoa) said :
#3

Hello,
any news regarding this problem?

Revision history for this message
matteoa (matteoa) said :
#4

with the last version I have another error message when trying to run a script that works if launched from the IDE or from command line:
C:\jython2.7.0\bin\jython.exe -Dpython.path=C:\SikuliX\Test_h20\PSA_Id_direct.sikuli C:/PSA_Id_direct.sikuli
C:\jython2.7.0\bin\jython.exe: No module named __main__
Picked up _JAVA_OPTIONS: -Xmx1024M

Process finished with exit code 1

This is the version I've used today:
1.1.4-SNAPSHOT-#383-2019-09-26_13:41/Windows10.0/Java8(64)1.8.0_221-b27
Thanks in advance

Revision history for this message
matteoa (matteoa) said :
#5

Hi all,
I'm sorry, in the previous message I said something wrong, it was only a misconfiguration of the Pycharm, now it has exactly the same error of before with current Sikulix 1.1.4 version...

Revision history for this message
RaiMan (raimund-hocke) said :
#6

Ok, I will check the next days on my Win10

Revision history for this message
matteoa (matteoa) said :
#7

Hi RaiMan,
any news regarding this problem?
In the meantime a colleague of mine has installed everything and this problem is present also in his pc.

Revision history for this message
RaiMan (raimund-hocke) said :
#8

talking about this ?

Error loading Python DLL: C:\jython2.7.1\bin\python27.dll (error code 14001)

If yes, not yet checked - will try latest until monday.

If no:
please tell about the problem again.

Revision history for this message
matteoa (matteoa) said :
#9

Hello,
the Jython error is not the object of my question, the problem is that I'm not able to debug in Pycharm with latest versions.
I have saved a version from April that is in use when we have to debug line by line and works, but the latest builds have the error described above:
Traceback (most recent call last):
  File "MYPerfectlyWorkingScript.py", line 75, in <module>
    Debug.setUserLogFile(b + 'logs\\' + str(strLogName))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
Picked up _JAVA_OPTIONS: -Xmx1024M
Process finished with exit code -1

this is the piece of code executed at the very beginning of the script:

b=getBundleFolder()
strLogName=datetime.now().strftime('%Y%m%d_%H%M%S'+ "-DbgSiK.log")
Debug.setUserLogFile(b + 'logs\\' + str(strLogName))

The problem of the Python dll is still there but, so far, I'm able to use Jython 2.7.0 and I think is something related to my pc (a colleague of mine uses 2.7.1)
Thanks for support
Matteo

Revision history for this message
RaiMan (raimund-hocke) said :
#10

as already mentioned in #1:

getBundleFolder() in your environment returns None (no bundle path defined)

try this:
scriptFile = argv[0] # Python standard behavior
scriptFolder = os.path.dirname(scriptFile)
strLogName=datetime.now().strftime('%Y%m%d_%H%M%S'+ "-DbgSiK.log")
Debug.setUserLogFile(makePath(scriptFolder, 'logs', strLogName))

Revision history for this message
matteoa (matteoa) said :
#11

hello,
I tried your workaround but there were an error:
Traceback (most recent call last):
  File "MYPerfectlyWorkingScript.py", line 95, in <module>
    scriptFile = argv[0] # Python standard behavior
NameError: name 'argv' is not defined
Picked up _JAVA_OPTIONS: -Xmx1024M
Process finished with exit code -1

I solved it by using sys.argv[0], thanks!

The little problem remaining is that within the IDE "my old version" works, and also using PyCharm works well, but only with older version of SikulixAPI, but it is something we can overcome until fixing.

Thanks for your, usual and very rare, prompt support!!!

Can you help with this problem?

Provide an answer of your own, or ask matteoa for more information if necessary.

To post a message you must log in.