ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Another Syntax errors in pychartdir.py
Posted by feedback@quantlabs.net on Feb-04-2021 08:51
Hi there
I have upgraded my Python3 to interpreter to v 3.8 with the latest version of Chart Director. When I run this:

from FinanceChart import *
from pychartdir import *

I get these syntax errors:

>>> from FinanceChart import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/quantlabsnet/DOCS/Documents/python/chartdir/ChartDirector/lib/FinanceChart.py", line 2, in <module>
    from pychartdir import *
  File "/Users/quantlabsnet/DOCS/Documents/python/chartdir/ChartDirector/lib/pychartdir.py", line 5, in <module>
    cdDll = __import__("pychartdir" + cdSysVer[0] + cdSysVer[2])
ImportError: dlopen(/Users/quantlabsnet/DOCS/Documents/python/chartdir/ChartDirector/lib/pychartdir38.so, 2): no suitable image found.  Did find:
/Users/quantlabsnet/DOCS/Documents/python/chartdir/ChartDirector/lib/pychartdir38.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
/Users/quantlabsnet/DOCS/Documents/python/chartdir/ChartDirector/lib/pychartdir38.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00

I have tried to follow the solutions as found here

https://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1565671383

I have copied the latest *.so files and pychartdir.py to my folder of

/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages

How does one resolve this error to proceed?

Thanks

  Re: Another Syntax errors in pychartdir.py
Posted by Peter Kwan on Feb-04-2021 21:03
Hi,

From the directory name "/Library/Framework/Python.framework/...", it seems you are using macOS. However, the "0x7F 0x45 0x4C 0x46 ....." looks like the header for the ELF format, which is used for Linux. Are you sure you have downloaded the macOS edition of ChartDirector?

In the macOS edition of ChartDirector, the pychartdir38.so should be 40144 bytes in size/ Would you mind to check if this is the case? The download should be called "chartdir_python_mac.tar.gz".

Regards
Peter Kwan

  Re: Another Syntax errors in pychartdir.py
Posted by feedback@quantlabs.net on Feb-05-2021 03:47
Thanks for the tip. You were correct. I accidentally installed the Linux version but removed it. I then installed a fresh copy of ChartDirector for Mac. I replaced all the /lib *.so and *.py in my directory of
/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages


As try to run this command in my Python 3.8 interpreter:

>>>from pychartdir import *

I got this exception:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/quantlabsnet/DOCS/Documents/python/ChartDirector/lib/pychartdir.py", line 14, in <module>
    raise ImportError('Version mismatch - "pychartdir.py" is of version %s.%s, but "chartdir.dll/libchartdir.so" is of version %s.%s' % ((cdPyVer >> 8) & 0xff, cdPyVer & 0xff, (cdDllVer >> 8) & 0xff, cdDllVer & 0xff))
ImportError: Version mismatch - "pychartdir.py" is of version 6.0, but "chartdir.dll/libchartdir.so" is of version 6.3

Is there anything I am doing wrong to get this working ?
Thanks

  Re: Another Syntax errors in pychartdir.py
Posted by Peter Kwan on Feb-05-2021 11:08
ChartDirector for Python includes the file "pychartdir.py", as well as the ChartDirector shared objects. Their version must match.

Sometimes people will copy the "pychartdir.py" to the directory that contains their own scripts. When the ChartDirector is updated, they forget to update the "pychartdir.py" in their own directory. That would cause the version mismatch error.

For your case, you updated the ChartDirector for Python in "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages". Your code is using the "pychartdir.py" in "/Users/quantlabsnet/DOCS/Documents/python/ChartDirector/lib/pychartdir.py", which is probably from an older version of ChartDirector. To solve the problem, you may try:

(a) Delete the "pychartdir.py" in your own directory, so that Python will search for the "pychartdir.py" in the "site-packages" directory. In this way, the "pychartdir.py" will always match the version of the shared objects.

or

(b) Install ChartDirector for Python (including the "pychartdir.py" and the shared objects) in your own directory instead of "site-packages". The "pychartdir.py" will then always match with the version of the shared objects.

or

(c) Replace the "pychartdir.py" in your own directory with the updated "pychartdir.py" in "site-packages".

Regards
Peter Kwan

  Re: Another Syntax errors in pychartdir.py
Posted by feedback@quantlabs.net on Feb-05-2021 11:38
Hi Peter, Thanks for pointing this out. This is now resolved. i had previous older ChartDirector reference in my PYTHONPATH. Stupid things you would never consider.

Thanks for the help