Robotics StackExchange | Archived questions

pkg_resources.DistributionNotFound: The 'rospkg==1.2.3' distribution was not found and is required by the application

When is run 'roscore' command in my terminal, I get an error:

  .. logging to /home/rahul/.ros/log/1676e6fa-abd6-11ea-8f43-70c94eedebaf/roslaunch-rahul-ubuntu-18-384.log
Checking log directory for disk usage. This may take a while.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.
Traceback (most recent call last):
  File "/home/rahul/.local/bin/rosversion", line 6, in 
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3088, in 
    @_call_aside
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 576, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 589, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'rospkg==1.2.3' distribution was not found and is required by the application
RLException: Invalid  tag: Cannot load command parameter [rosversion]: command [['rosversion', 'roslaunch']] returned with code [1]. 

Param xml is param command="rosversion roslaunch" name="rosversion" />  
The traceback for the exception was written to the log file

I'm running ROS melodic on Ubuntu 18.04. Kernel version: Linux 5.3.0-59-generic x86_64

This is what I get when I run 'printenv | grep ROS':

ROSETCDIR=/opt/ros/melodic/etc/ros
ROSROOT=/opt/ros/melodic/share/ros
ROSMASTERURI=http://localhost:11311
ROSVERSION=1
ROSPYTHONVERSION=2
ROSPACKAGEPATH=/home/rahul/Desktop/edxws/src:/opt/ros/melodic/share
ROSLISPPACKAGEDIRECTORIES=/home/rahul/Desktop/edxws/devel/share/common-lisp
ROS_DISTRO=melodic

I did 'pip install rospkg'. Even after installation I get the same error.

I'm a beginner in ROS. Thank you for your time.

Asked by Rahul K R on 2020-06-11 06:51:06 UTC

Comments

Hey there, I have the same problem on armhf Debian 10 for ROS2 Foxy.

pip3 install rospkg
tells me that the package is already the latest version

apt install python-rospkg tells me it can't find the package with:

"E: Failed to fetch http://ftp.us.debian.org/debian/pool/main/p/pillow/python-pil_5.4.1-2+deb10u2_armhf.deb 404 Not Found"

Am I guessing correctly that there are no debian packages for armhf available for python-rospkg?

I cross compiled ros2 myself for this armhf Debian 10..

Any help would be greatly appreciated.

Thank you

Asked by pennjamin on 2022-04-28 11:13:07 UTC

can you try apt install python3-rospkg? The ros2 distributions rely on python3.

Asked by ignacio on 2022-05-10 03:20:23 UTC

Answers

The following command fixed the error for me.

$ sudo chown -R ~/.ros

Asked by Rahul K R on 2020-06-11 23:47:12 UTC

Comments

I use sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/lsb_release -csmain" > /etc/apt/sources.list.d/ros-latest.list' mirro. My problem is pkg_resources.DistributionNotFound: The 'rospkg>=1.2.7' distribution was not found and is required by rosdep, solved with pip install rospkg==1.2.7 -i https://pypi.tuna.tsinghua.edu.cn/simple, hope to be useful.

Asked by jxl on 2021-03-17 02:42:32 UTC

Comments

I meet the same problem,sovled it by using

pip3 install rospkg==1.2.8

Asked by nkym on 2021-04-15 10:01:25 UTC

Comments

This solution has worked for me:

  1. Installing last rospkg version pip3 install rospkg -U
  2. Then changing the version number in sudo nano /usr/local/bin/rosversion

Asked by bhomaidan on 2022-03-01 14:49:08 UTC

Comments

if you don't have pip installed, you can also use apt install python-rospkg

Asked by ignacio on 2022-04-28 10:13:28 UTC

Comments