'Get error when I use pyc instead py or ROS
I am using ROS Noetic. I tried to use the pyc file instead py to hide the src file. But, always I got this error:
RuntimeError: Bad magic number in .pyc file
To compile my ROS node, the first step is to generate the file.pyc with
python3.8 -m compileall file.py
And I got a file.pyc with the magic number 550d which corresponds to the version of python 3.8 Now, I changed the line int CMakeLists.txt to:
catkin_install_python(PROGRAMS scripts/file.pyc
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
Then, when I run the node I got the same error. I checked the magic number of file.py and /devel/lib/file_package/file.pyc, I found that have 2321 which does not match to any version, even when I added this option:
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python3.8
Also, the magic number of file.pyc will be changed to 2321 in /devel/lib/file_package/file.pyc after the compilation.
Any, help please?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
