udacity / udacidrone

An API for working with flying objects, simulated, unidentified, and otherwise.
https://udacity.github.io/udacidrone
129 stars 96 forks source link

udacidrone breaks when running on Python 3.7 #61

Open cptanalatriste opened 2 years ago

cptanalatriste commented 2 years ago

I'm trying to use udacidrone to run code on a Crazyflie, using an Anaconda environment with Python 3.7 installed (as required by the Crazyflie Python client. However, when running the udacidrone code I gert the following:

Traceback (most recent call last):
  File "/home/cgc87/PycharmProjects/crazyflie/backyard_flyer.py", line 8, in <module>
    from udacidrone.connection import CrazyflieConnection  # noqa: F401
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/udacidrone/connection/__init__.py", line 6, in <module>
    from .websocket_connection import WebSocketConnection
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/udacidrone/connection/websocket_connection.py", line 8, in <module>
    import websockets
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/websockets/__init__.py", line 3, in <module>
    from .client import *
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/websockets/client.py", line 20, in <module>
    from .protocol import WebSocketCommonProtocol
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/websockets/protocol.py", line 18, in <module>
    from .compatibility import asyncio_ensure_future
  File "/home/cgc87/anaconda3/envs/crazyflie/lib/python3.7/site-packages/websockets/compatibility.py", line 15
    asyncio_ensure_future = asyncio.async           # Python < 3.5
                                        ^
SyntaxError: invalid syntax

It appears the websocket version is generating invalid Python 3.7 code. I tried updating websockets, but it breaks in many other ways.

Is there a workaround for udacidrone to work on Python 3.7?

yevtu commented 8 months ago

Hey @cptanalatriste, have you managed to solve this issue? It's still reproducing.

yfe404 commented 8 months ago

Hey, I managed to modify websocket so that it's working with udacidrone on Python3.7. I have made a Dockerfile https://github.com/yfe404/Drone-Flight-Controller-Sim-Backyard-Flyer but alternatively you can just replace

/usr/local/lib/python3.7/site-packages/websockets/__init__.py with my custom_init.py /usr/local/lib/python3.7/site-packages/websockets/compatibility.py with my custom_compatibility.py

cptanalatriste commented 8 months ago

Hey @cptanalatriste, have you managed to solve this issue? It's still reproducing.

Sadly, I didn't manage to get it working. I ended abandoning the Crazyflie during the Nanodegree :(

yevtu commented 8 months ago

Sadly, I didn't manage to get it working. I ended abandoning the Crazyflie during the Nanodegree :(

Really sad to hear this about the program which positions itself as paid personalized people-oriented experience.


Anyway, for those who having trouble creating conda env with python==3.6 on MacOS M1, try to install conda for x86 instead of arm64