1

want to create a python 3.6 environment. Below are the commands I executed and the output, but as you can see, the last python version shows 2.7. Why is this? I re-exit the terminal, re-enter, still 2.7 version

(base) :~/workspace/gem5$ conda create -n rcnn python=3.6
        Collecting package metadata (current_repodata.json): done
        Solving environment: done

    ## Package Plan ##

    environment location: /home/cuiyujie/anaconda3/envs/rcnn

    added / updated specs:
        - python=3.6


    The following packages will be downloaded:

        package                    |            build
        ---------------------------|-----------------
        certifi-2016.2.28          |           py36_0         214 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        pip-9.0.1                  |           py36_1         1.7 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        python-3.6.2               |                0        31.5 MB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        setuptools-36.4.0          |           py36_1         534 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        wheel-0.29.0               |           py36_0         129 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        wincertstore-0.2           |           py36_0          14 KB  http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
        ------------------------------------------------------------
                                            Total:        34.1 MB

    The following NEW packages will be INSTALLED:

    certifi            anaconda/pkgs/free/win-64::certifi-2016.2.28-py36_0
    pip                anaconda/pkgs/free/win-64::pip-9.0.1-py36_1
    python             anaconda/pkgs/free/win-64::python-3.6.2-0
    setuptools         anaconda/pkgs/free/win-64::setuptools-36.4.0-py36_1
    vc                 anaconda/pkgs/free/win-64::vc-14-0
    vs2015_runtime     anaconda/pkgs/free/win-64::vs2015_runtime-14.0.25420-0
    wheel              anaconda/pkgs/free/win-64::wheel-0.29.0-py36_0
    wincertstore       anaconda/pkgs/free/win-64::wincertstore-0.2-py36_0


    Proceed ([y]/n)? y


    Downloading and Extracting Packages
    python-3.6.2         | 31.5 MB   | ################################################################################################################################ | 100%
    wheel-0.29.0         | 129 KB    | ################################################################################################################################ | 100%
    setuptools-36.4.0    | 534 KB    | ################################################################################################################################ | 100%
    certifi-2016.2.28    | 214 KB    | ################################################################################################################################ | 100%
    wincertstore-0.2     | 14 KB     | ################################################################################################################################ | 100%
    pip-9.0.1            | 1.7 MB    | ################################################################################################################################ | 100%
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    #
    # To activate this environment, use
    #
    #     $ conda activate rcnn
    #
    # To deactivate an active environment, use
    #
    #     $ conda deactivate

(base) :~/workspace/gem5$ conda activate rcnn
(rcnn) :~/workspace/gem5$ python --version
        Python 2.7.12
(rcnn) :~/workspace/gem5$

At the end of my .bashrc is export PATH="/home/cuiyujie/anaconda3/bin:$PATH". This shows that the path of my anaconda is put to the front, but when I use echo $PATH, the output is /home/cuiyujie/bin:/home/cuiyujie/.local/bin:/home/cuiyujie/anaconda3/bin:/home/cuiyujie /anaconda3/condabin:/usr/local/sbin:. Why did Anaconda run behind again? When I use the export PATH="/home/cuiyujie/anaconda3/bin:$PATH command directly in the terminal.

echo $PATH is

/home/cuiyujie/anaconda3/bin:/home/cuiyujie/bin:/home/cuiyujie/.local/bin:/home/cuiyujie/anaconda3/bin:/home/cuiyujie/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/arm_4.4.3/bin

I tried the conda command again and checked the python version

(base) :~$ conda activate rcnn
(rcnn) :~$ python --version
Python 3.8.5

The version is 3.85, which is the same as the built-in version, not the 3.6 I created

   (rcnn) :~$ which python
/home/cuiyujie/anaconda3/bin/python
(rcnn) :~$ echo $PATH
/home/cuiyujie/anaconda3/envs/rcnn/bin:/home/cuiyujie/bin:/home/cuiyujie/.local/bin:/home/cuiyujie/anaconda3/bin:/home/cuiyujie/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/arm_4.4.3/bin

I am using the linux version. I am sure I downloaded the Linux version.Anaconda3-2020.07-Linux-x86_64.sh But I entered the package of the environment I created, which contained .ddl and exe files, which was so strange. I uninstalled and reinstalled it several times. But Anaconda is the linux version, and the created environment is the window version.

Gerrie
  • 736
  • 3
  • 18
  • 1
    Does this answer your question? [Mac using default Python despite Anaconda install](https://stackoverflow.com/questions/22773432/mac-using-default-python-despite-anaconda-install) – bigbounty Jan 19 '21 at 02:19
  • I should have the same problem. But that does not have my answer. At the end of my .bashrc is export PATH="/home/cuiyujie/anaconda3/bin:$PATH". This shows that the path of my anaconda is put to the front, but when I use echo $PATH, /home/cuiyujie/bin:/home/cuiyujie/.local/bin:/home/cuiyujie/anaconda3/bin:/home/cuiyujie /anaconda3/condabin:/usr/local/sbin:. Why did Anaconda run behind again? – Gerrie Jan 19 '21 at 02:35
  • 1
    Note that such manual manipulation of PATH has been deprecated since Conda v4.4, particularly because it is antagonist to properly insulating environments. Instead, please use `conda init bash` to add the recommended initialization code to `.bashrc` and remove the manual manipulation. As for the `.local/bin` being prepended, are you using any shell persistence software (e.g., `tmux` or `screen`)? Sometimes these can execute additional manipulations of environment variables, interfering with what Conda expects. – merv Jan 19 '21 at 06:12

3 Answers3

1

Did you alias python=/path/to/python2.7 ?

Or maybe you can try:

conda deactivate
conda activate rcnn

Check which python you are using by:

which python
yuanmu
  • 11
  • 1
  • I tried it and I added the result to the above question – Gerrie Jan 19 '21 at 02:44
  • I checked my $PATH, The only thing different in the $PATH is this part: `/home/cuiyujie/bin:/home/cuiyujie/.local/bin`, I don't have a corresponding one. I am not sure whether it is the problem. And did you check `/home/cuiyujie/anaconda3/envs/rcnn/bin/python --version`? – yuanmu Jan 19 '21 at 03:07
1

Anaconda Navigator is for Setting up an environment or installing/updating packages in a specific environment of your choice. If you are having a new environment set up say, previously u have an existing 3.5 and now you are setting up 3.7 then, you will have to install the spyder kernel. Dont worry, when you start the system will flag this and you just have to install that through Navigator.

[Spyder > Tools > Preferences][1] [1]: https://i.stack.imgur.com/qoSDV.png

Here in Spyder, your editor you typically would have the default python interpretor, change it to the environment of your choice.

[Prefernce > Set new python exe from specific environment][2] [2]: https://i.stack.imgur.com/XiQro.png

So when you click on the Use the following interpretor, and open the file , you need to browse to the anaconda environment, select the respective version.

[Select Python Version][3] [3]: https://i.stack.imgur.com/u4vQm.png

Now apply and say ok.

You need to restart your spyder for this to take effect for the first time.

mrai
  • 11
  • 2
0

It's very simple using Anaconda Navigator. Just choose your right environment and select Python version from the list. Check the screenshots for more clarity.

enter image description here

enter image description here

Anand
  • 2,239
  • 4
  • 32
  • 48