On Ubuntu 16.04 I created an environment with this command:
conda create -n ros2 python=2.7
And then activated it like so: conda activate ros2
But then python --version
gives "Python 3.5.2"
Why is this so? How can I set the version of python to be 2.7?
which python
gives "/home/brads/anaconda3/envs/ros2/bin/python"
echo $PATH
gives: "/opt/ros/kinetic/bin:/home/brads/anaconda3/envs/ros2/bin:/home/brads/anaconda3/condabin:/home/brads/bin:/home/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"
Contents of /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
Output of which -a python
:
/home/brads/anaconda3/envs/ros2/bin/python
/usr/bin/python
Output of python -c "import sys; print(sys.executable)"
: "/usr/bin/python3"
Output of 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
which python
orwhere python
(the former for Linux/macOS, the latter for Windows). If on Windows, are you using the Anaconda Prompt? If on Linux/macOS, what is the output ofecho $PATH
? – darthbithwhich -a python
andpython -c "import sys; print(sys.executable)"
? – darthbith