conda deactivate python3没用了,python conda:创建了一个环境,但是没有使用conda的python...

I have been using anaconda for a while, and its Python executable is located at /Users/ufo/opt/anaconda3/bin/python. I have tried to create an environment with conda, and the new environment would use copy this Python to environment's bin.

However, with current Anaconda versation, the new environment will not use anaconda's Python, but use the original Python pre-installed with Mac OS, which was python 2.*.

Here is a snip of checking anaconda python version, creating/activating new environment, and checking again. From the snip I noticed the change of $PATH as well as Python versions.

How can I still use anaconda's Python in new environment?

(base) ufo@ufodeMacBook-Pro:~$ echo $PATH

/Users/ufo/opt/anaconda3/bin:/Users/ufo/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

(base) ufo@ufodeMacBook-Pro:~$ which python

/Users/ufo/opt/anaconda3/bin/python

(base) ufo@ufodeMacBook-Pro:~$ python -V

Python 3.7.5

(base) ufo@ufodeMacBook-Pro:~$ conda info -e

# conda environments:

#

base * /Users/ufo/opt/anaconda3

(base) ufo@ufodeMacBook-Pro:~$ conda create -n msg

Collecting package metadata (current_repodata.json): done

Solving environment: done

## Package Plan ##

environment location: /Users/ufo/opt/anaconda3/envs/msg

Proceed ([y]/n)?

Preparing transaction: done

Verifying transaction: done

Executing transaction: done

#

# To activate this environment, use

#

# $ conda activate msg

#

# To deactivate an active environment, use

#

# $ conda deactivate

(base) ufo@ufodeMacBook-Pro:~$ conda activate msg

(msg) ufo@ufodeMacBook-Pro:~$ which python

/usr/bin/python

(msg) ufo@ufodeMacBook-Pro:~$ echo $PATH

/Users/ufo/opt/anaconda3/envs/msg/bin:/Users/ufo/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

(msg) ufo@ufodeMacBook-Pro:~$ conda info -e

# conda environments:

#

base /Users/ufo/opt/anaconda3

msg * /Users/ufo/opt/anaconda3/envs/msg

(msg) ufo@ufodeMacBook-Pro:~$ python -V

Python 2.7.10

(msg) ufo@ufodeMacBook-Pro:~$

解决方案

An easy workaround would be to export the path to the python you require once you activate the environment. As can be seen in the below snipet.

export PATH=/Users/ufo/opt/anaconda3/bin/:$PATH

you can then use which python to see if your python is rightly set

To use your environments python do

export PATH=/Users/ufo/opt/anaconda3/envs/msg/bin/:$PATH

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值