Error on import ros packages
I`m trying to write a ros module in python, but I'm facing this issue below:
import: not authorized `rospy' @ error/constitute.c/WriteImage/1028.
from: can't read /var/mail/sensor_msgs.msg
from: can't read /var/mail/tf2_msgs.msg
from: can't read /var/mail/geometry_msgs.msg
from: can't read /var/mail/cv_bridge
Is there any configuration wrong in CmkaList.txt or package.xml? Am I missing any file for cmake compile correctly python code?
EDIT #1: Added code
#!/usr/bin/env python
import rospy
from sensor_msgs.msg import Image,CameraInfo
from tf2_msgs.msg import TFMessage
from geometry_msgs.msg import TransformStamped
from cv_bridge import CvBridge
import airsim
import cv2
import numpy as np here
EDIT #2: The script is already executable chmod u+x script.py
Looks to me like this is most likely an issue with the
#!
at the beginning of your Python script. Can you please edit your question and copy-paste the first few lines of the script you are referring to?I check
/usr/bin/
and it is emptyThat's strange. On most systems, at the terminal, if you just type
/usr/bin/env python
it should automatically launch your default Python interpreter. Does that work on your machine? If not, what Linux distro are you on? You could probably work around this issue by replacing the string after...... the
#!
to just be the full path to your default Python executable. For example,#!/usr/bin/python
. You could usewhich python
in a terminal to figure out the full path of your default Python.As a side note, the
error/constitute.c/WriteImage/1028.
error you are seeing is because your system is not properly using Python as the interpreter to parse this script. Instead it is likely using eithersh
orbash
. The commandimport
is part of ImageMagick so you are effectively trying to..... run the ImageMagick command line tool
import
on a file namedrospy
, and that is throwing the error. To read more about this, check out the shebang Wikipedia page: https://en.wikipedia.org/wiki/Shebang...One other thought.... are you sure that the
#!
is the absolute first two characters in the script? It is in the snippet you posted, but that could be a copy-paste relic. If you have a blank line at the top of your script, you'll get exactly the error you are showing.I found the errror: there was a space before
#!
, at the beginning. Thanks @jarvisschultz for your help