ros2和anaconda结合
-
系统是ubuntu22.04,目前用anaconda创建了一个python环境,想在ros中使用pytorch,按照该方法尝试了一下,添加了
import sys sys.path.append('/home/xl/anaconda3/envs/drl/lib/python3.8/site-packages') import torch
并且关闭了conda进行编译和运行,但是报了如下的错误
Traceback (most recent call last): File "/home/xl/ros2_ws/install/py_pubsub/lib/py_pubsub/talker", line 33, in <module> sys.exit(load_entry_point('py-pubsub==0.0.0', 'console_scripts', 'talker')()) File "/home/xl/ros2_ws/install/py_pubsub/lib/py_pubsub/talker", line 25, in importlib_load_entry_point return next(matches).load() File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load module = import_module(match.group('module')) File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1050, in _gcd_import File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 688, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 883, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/home/xl/ros2_ws/install/py_pubsub/lib/python3.10/site-packages/py_pubsub/publisher_member_function.py", line 18, in <module> import torch File "/home/xl/anaconda3/envs/drl/lib/python3.8/site-packages/torch/__init__.py", line 443, in <module> raise ImportError(textwrap.dedent(''' ImportError: Failed to load PyTorch C extensions: It appears that PyTorch has loaded the `torch/_C` folder of the PyTorch repository rather than the C extensions which are expected in the `torch._C` namespace. This can occur when using the `install` workflow. e.g. $ python setup.py install && python -c "import torch" This error can generally be solved using the `develop` workflow $ python setup.py develop && python -c "import torch" # This should succeed or by running Python from a different directory. [ros2run]: Process exited with failure 1
-
@tempxl 重新用virtulenv创建了一个虚拟环境,并且装上pytorch,发现可以正常使用
-
@tempxl anacoda3的python版本和系统的ros版本应该不匹配
-
@小鱼 是的,anaconda创建的是python3.8,系统的是3.10
-
-
@tempxl 在 ros2和anaconda结合 中说:
@小鱼 是的,anaconda创建的是python3.8,系统的是3.10
你好,我也遇到了这个问题,我在conda环境python是3.7,系统是3.10, 因为想利用conda环境里的tensorflow包,然后在环境里运行不了,不知道是否因为两者python版本部匹配所导致的。
-
@tempxl 在 ros2和anaconda结合 中说:
重新用virtulenv创建了一个虚拟环境,并且装上pytorch,发现可以正常使用
只能重新创建虚拟环境吗?我现在跑的视觉只支持3.8版本的怎么办?