(base) wang@wang:~$ python --version
Python 3.10.12
(base) wang@wang:~$ conda deactivate
wang@wang:~$ python --version
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
wang@wang:~$ type python python2 python3
bash: type: python: not found
bash: type: python2: not found
python3 is /usr/bin/python3
wang@wang:~$ python3 --version
Python 3.10.12
wang@wang:~$ conda create -n ros2 python=3.10.12
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 23.5.2
latest version: 23.7.2
Please update conda by running
$ conda update -n base -c defaults conda
Or to minimize the number of packages updated during conda update use
conda install conda=23.7.2
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import rclpy
2 from rclpy.node import Node
File /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/__init__.py:49
47 from rclpy.context import Context
48 from rclpy.parameter import Parameter
---> 49 from rclpy.signals import install_signal_handlers
50 from rclpy.signals import SignalHandlerOptions
51 from rclpy.signals import uninstall_signal_handlers
File /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/signals.py:15
1 # Copyright 2019 Open Source Robotics Foundation, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 15 from rclpy.exceptions import InvalidHandle
16 from rclpy.guard_condition import GuardCondition
17 from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
File /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/exceptions.py:15
1 # Copyright 2016 Open Source Robotics Foundation, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
(...)
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
---> 15 from rclpy.impl.implementation_singleton import rclpy_implementation as _rclpy
18 class NotInitializedException(Exception):
19 """Raised when the rclpy implementation is accessed before rclpy.init()."""
File /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/impl/implementation_singleton.py:32
29 from rpyutils import import_c_library
30 package = 'rclpy'
---> 32 rclpy_implementation = import_c_library('._rclpy_pybind11', package)
File /opt/ros/humble/lib/python3.10/site-packages/rpyutils/import_c_library.py:39, in import_c_library(name, package)
34 try:
35 # Since Python 3.8, on Windows we should ensure DLL directories are
36 # explicitly added to the search path.
37 # See https://docs.python.org/3/whatsnew/3.8.html#bpo-36085-whatsnew
38 with add_dll_directories_from_env('PATH'):
---> 39 return importlib.import_module(name, package=package)
40 except ImportError as e:
41 distro = os.environ.get('ROS_DISTRO', 'rolling')
File ~/miniconda3/envs/ros2/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
124 break
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
ImportError: /home/wang/miniconda3/envs/ros2/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so)
The C extension '/opt/ros/humble/local/lib/python3.10/dist-packages/rclpy/_rclpy_pybind11.cpython-310-x86_64-linux-gnu.so' failed to be imported while being present on the system. Please refer to 'https://docs.ros.org/en/{distro}/Guides/Installation-Troubleshooting.html#import-failing-even-with-library-present-on-the-system' for possible solutions
(base) wang@wang:~$ conda deactivate
wang@wang:~$ ll /home/wang/miniconda3/lib/libstdc++.so.6
lrwxrwxrwx 1 wang wang 19 8月 17 02:57 /home/wang/miniconda3/lib/libstdc++.so.6 -> libstdc++.so.6.0.29*
wang@wang:~$
cd /home/wang/miniconda3/lib/
strings libstdc++.so.6 | grep GLIBCXX_3.4.30
locate libstdc++.so.6
strings libstdc++.so.6|grep GLIBCXX
文件(动态链接指向的文件)出问题
不在conda虚拟环境安装解决问题