Coder Social home page Coder Social logo

Cannot import c_common about pymodes HOT 8 CLOSED

junzis avatar junzis commented on July 30, 2024
Cannot import c_common

from pymodes.

Comments (8)

jmceara avatar jmceara commented on July 30, 2024

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

from pymodes.

imanolpg avatar imanolpg commented on July 30, 2024

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 c_common.pxd and c_common.pyx

from pymodes.

junzis avatar junzis commented on July 30, 2024

@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.

from pymodes.

xoolive avatar xoolive commented on July 30, 2024

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

from pymodes.

jmceara avatar jmceara commented on July 30, 2024

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?

from pymodes.

junzis avatar junzis commented on July 30, 2024

This seems strange. But I can't reproduce this.

Please provide a minimum working example, and the pyModeS version you are using.

from pymodes.

jmceara avatar jmceara commented on July 30, 2024

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.

from pymodes.

junzis avatar junzis commented on July 30, 2024

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.

from pymodes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.