在Ubuntu 16.04上,我使用以下命令创建了一个环境:
conda create -n ros2 python=2.7
然后像这样激活它:conda activate ros2
但是随后python --version
给出了“ Python 3.5.2”
为什么会这样?如何将python的版本设置为2.7?
which python
给出了“ / home / brads / anaconda3 / envs / ros2 / bin / python”
echo $PATH
给出:“ / opt / ros / kinetic / bin:/ home / brads / anaconda3 / envs / ros2 / bin:/ home / brads / anaconda3 / condabin:/ home / brads / bin:/主页/brads/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games :/ usr / local / cuda / bin:/ snap / bin“
/opt/ros/kinetic/bin
的内容:
binvox2bt edit_octree opencv_waldboost_detector roslaunch-deps rosservice rqt_dep stage
bt2vrml eval_octree_accuracy rosbag roslaunch-logs rossrv rqt_graph tf_remap
catkin_find graph2tree rosboost-cfg rosmake rosstack rqt_image_view view_frames
catkin_init_workspace log2graph rosclean rosmaster rostest rqt_logger_level xacro
catkin_make opencv_annotation rosconsole rosmsg rostopic rqt_plot
catkin_make_isolated opencv_createsamples roscore rosmsg-proto rosunit rqt_shell
catkin_test_results opencv_interactive-calibration roscreate-pkg rosnode roswtf run_selftest
catkin_topological_order opencv_traincascade rosgraph rospack rqt rviz
compare_octrees opencv_version roslaunch rosparam rqt_bag selftest_example
convert_octree opencv_visualisation roslaunch-complete rosrun rqt_console selftest_rostest
which -a python
的输出:
/home/brads/anaconda3/envs/ros2/bin/python
/usr/bin/python
python -c "import sys; print(sys.executable)"
的输出:“ / usr / bin / python3”
env | grep "PYTHON"
的输出
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.5
PYTHONPATH=/opt/ros/kinetic/lib/python2.7/dist-packages:/home/brads/anaconda3/envs/ros2/lib/python2.7/site-packages/
CONDA_PYTHON_EXE=/home/brads/anaconda3/bin/python
答案 0 :(得分:2)
问题似乎是在conda之前安装的virtualenv_wrapper。我通过pip uninstall virtualenvwrapper
删除了,我也在~/.profile
中删除了对它的引用,然后重新登录