Erro while compiling a simlple package on Rosject

Hi,

I’m trying to compile a simple package on rosject env. with no success.
I have done several packages on the ros2 tutorial env with no issues, but for some reason it not working on the simulator.

user:~/ros2_ws$ colcon build
Starting >>> my_package
Traceback (most recent call last):- 2.1s]
File “”, line 1, in
File “/usr/lib/python3.8/distutils/core.py”, line 215, in run_setup
exec(f.read(), g)
File “”, line 2
import os
^
SyntaxError: invalid character in identifier
— stderr: my_package

Thanks
Gal

Hello @gpitarasho ,

Are you trying to compile a Python script? It looks like there might be some error in your code (maybe a strange character got copied when copy/pasting a code). Could you share your code here?

Hi,
Yes I’m trying to compile a python package.
After having issues, I tried to compile a simple package w/ minimal content.
The issue is in the setup.py file, see code attached below.
The error is on the import os, which is a basic import.
The same code is working in the course environment but is not working on the course project env.
Thanks
Gal

from setuptools import setup
import os
from glob import glob

package_name = ‘my_package’

setup(
name=package_name,
version=‘0.0.0’,
packages=[package_name],
data_files=[
(‘share/ament_index/resource_index/packages’,
[‘resource/’ + package_name]),
(‘share/’ + package_name, [‘package.xml’]),
(os.path.join(‘share’, package_name), glob(‘launch/*.launch.py’))
],

install_requires=['setuptools'],
zip_safe=True,
maintainer='user',
maintainer_email='user@todo.todo',
description='TODO: Package description',
license='TODO: License declaration',
tests_require=['pytest'],
entry_points={
    'console_scripts': [
        'my_package=my_package.my_package:main'
    ],
},

)

Hello @gpitarasho ,

Please try to delete the lines of code which are giving you the errors and type them again by hand. I suspect that some strange characters might have been added during the copy/paste process.

Indeed that was the issue.
Thanks a lot!
I couldn’t understand how a simple package is not working.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.