Closed jmceara closed 3 years ago
Ok, I've removed packages (pyModeS*) from .local dir (in home from user) and from /usr/local/lib/python3.5/dist-packages/. Done install again.....still same problem, with different path:
pi@rasp3_dev:~/pyModeS $ modeslive --help
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pyModeS-2.8-py3.5.egg/pyModeS/__init__.py", line 5, in <module>
from . import c_common as common
ImportError: cannot import name 'c_common'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/modeslive", line 4, in <module>
__import__('pkg_resources').run_script('pyModeS==2.8', 'modeslive')
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 1494, in run_script
exec(code, namespace, namespace)
File "/usr/local/lib/python3.5/dist-packages/pyModeS-2.8-py3.5.egg/EGG-INFO/scripts/modeslive", line 10, in <module>
from pyModeS.streamer.decode import Decode
File "/usr/local/lib/python3.5/dist-packages/pyModeS-2.8-py3.5.egg/pyModeS/__init__.py", line 8, in <module>
from . import py_common as common
File "/usr/local/lib/python3.5/dist-packages/pyModeS-2.8-py3.5.egg/pyModeS/py_common.py", line 130
addr: Optional[str]
^
SyntaxError: invalid syntax
Hello @jmceara.
Try removing and installing all again with pip: pip3 remove pyModeS
and pip3 install pyModeS
.
If the error is still there, make sure that in the module directory /usr/local/lib/python3.5/dist-packages/pyModeS exists the files _ccommon.pxd and _ccommon.pyx
@jmceara, @imanolpg, (and @xoolive FYI)
I did some tests with different Python versions. The error is caused by variable annotation (PEP 526) in the py_common
module. It only effects Python version 3.5 and below.
So, the simplest option is to update you Python to 3.6+ for now.
I will evaluate the code to see if we should keep the variable annotation, or make Python 3.6 the minimum required version in the setup.
Indeed variable annotation syntax is only valid from Python 3.6 (to put things in perspective, Python 3.9rc1 is just out!)
From Python 3.6 we can write
addr: Optional[str] = None
In Python 3.5, the following syntax is valid and should be readable by MyPy (second part to be confirmed...)
addr = None # type: Optional[str]
The first syntax is more flexible but the second should do the job if we just want type hints as information. So yes, in the end @junzis, the only question is when do you want to stop support for Python 3.5
ok, got it working with version 3.6.12 of python....but I have another problem. Now I'm getting this error:
File "./jonis.py", line 9, in <module>
if len(msg) > 20 and msg[0:4] == "A000" and pms.bds.bds44.is44(msg) :
AttributeError: module 'pyModeS' has no attribute 'bds'```
But this code is the smae as I was running before.....and also, this is the same code (isbds44) in the main README file. Maybe doc is outdated?
What's the correct way to check now?
This seems strange. But I can't reproduce this.
Please provide a minimum working example, and the pyModeS version you are using.
It's exaclty the same code from my first post in this issue, except for the python path that I've changed from #!/usr/bin/python3 -O
to #!/usr/local/bin/python3.6 -O
I'm using python 3.6.12. program modeslive
run fine, without any problem.
Note: Except for the import error in first msg of this topic, the code ran fine in previous version of python (and pyModeS). I mean, before updating pyModeS and python, I was using exactly the same code. I don't remember exactly which version of pyModeS, but it was before BDS4,5 was implemented, if I'm right.....am not sure.
I think it is a problem with installation.
Maybe try to remove pyModeS use pip uninstall, and then install it again to see if it solves the issue.
If it still doesn't work, try to install and run it the script in a python virtual environment.
If you are struggling with native python library on Linux, the easiest way is to use a python package management tool like anaconda.
Hi! I was using an old version of pyModeS to make some tests. Recently I've updated to latest version, installation is ok, but I can't run anything, even modeslive. It's a bug in pyModeS or am I missing something? I've setup python3 as default for my system.
also, I'm trying to use this script, but got the same import error: