【Ubuntu 系统使用进入,自动进入base虚拟环境解决最全】

news2024/9/23 13:25:15

项目场景:

在Ubuntu上安装完anaconda后,发现每次打开终端后都会自动进入到base的虚拟环境中去,虽然在这些环境下使用问题不大,但一些软件的安装在虚拟环境下有影响。每次使用conda deactivate退出也很麻烦。

问题描述

安装玩之后,打开终端,发现前面带有“base”,此时,可以输入如下命令,退出base环境:

conda deactivate

在这里插入图片描述

解决方案:

方法一:
打开终端,有base环境的,直接输入下面代码,然后新开终端,新开的便会退出环境

conda config --set auto_activate_base false

在这里插入图片描述

方法二:

永久取消base字样办法:
1、在新终端中输入:gedit ~/.bashrc
2、在打开的文件最后加上一句命令:conda deactivate
3、重新打开终端即可消除base字样。

若在终端中输入conda deactivate,也可消除base字样,但是一次性的,再次打开终端依然存在base字样。在.bashrc文件添加命令:conda deactivate可以永久消除base字样。

1,通过将auto_activate_base参数设置为false实现:

conda config --set auto_activate_base false

2,那要进入的话通过conda activate base

3,如果反悔了还是希望base一直留着的话通过
conda config --set auto_activate_base true
恢复

@Override
	public void run() {
		bytes = mmInStream.read(buffer);
		mHandler.obtainMessage(READ_DATA, bytes, -1, buffer).sendToTarget();
	}

解决:在anaconda安装时选择的初始化,.bashrc中的对应文件如下

#作用应该是一打开终端就初始化conda环境
 
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/s/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/s/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
 
 

把这段注释掉,如下

#不让conda自己初始化
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
#    eval "$__conda_setup"
#else
#    if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
#        . "/home/s/anaconda3/etc/profile.d/conda.sh"
#    else
#        export PATH="/home/s/anaconda3/bin:$PATH"
#    fi
#fi
#unset __conda_setup
# <<< conda initialize <<<

此时没有了(base)标志,但是输入python默认的是python2.7.这就是问题2

问题2:消除base后,在终端输入python时发现,此时python的版本不是对应anaconda版本里的

解决:在.bashrc文件末尾加上anaconda的路径,如下

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
 
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac
 
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
 
# append to the history file, don't overwrite it
shopt -s histappend
 
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
 
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
 
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
 
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
 
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi
 
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac
 
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
 
if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
	# We have color support; assume it's compliant with Ecma-48
	# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
	# a case would tend to support setf rather than setaf.)
	color_prompt=yes
    else
	color_prompt=
    fi
fi
 
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
 
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac
 
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'
 
    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
 
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
 
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
 
# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
 
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
 
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi
 
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi
 
 
#不让conda自己初始化
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
#__conda_setup="$('/home/s/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
#if [ $? -eq 0 ]; then
#    eval "$__conda_setup"
#else
#    if [ -f "/home/s/anaconda3/etc/profile.d/conda.sh" ]; then
#        . "/home/s/anaconda3/etc/profile.d/conda.sh"
#    else
#        export PATH="/home/s/anaconda3/bin:$PATH"
#    fi
#fi
#unset __conda_setup
# <<< conda initialize <<<
 
 
#显示conda下的Python
export PATH="/home/s/anaconda3/bin:$PATH"

执行

source .bashrc

输入python默认输出conda中的Python了
在这里插入图片描述

参考:
ubuntu18.04安装anaconda后终端出现base字样

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1152634.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

软件测试这些基本类型你知道吗

关于软件测试的类型&#xff0c;从不同角度来讲&#xff0c;可以分很多种&#xff0c;有时候甚至觉得软件测试是人类创造出来的最复杂的职业。。。 对一些常见的测试类型做了一个基本的文档总结&#xff0c;有些测试类型在之前的基础知识里面已经有所介绍&#xff0c;这里就没…

【Python爬虫+可视化】解析小破站热门视频,看看播放量为啥会这么高!评论、弹幕主要围绕什么展开

大家早好、午好、晚好吖 ❤ ~欢迎光临本文章 如果有什么疑惑/资料需要的可以点击文章末尾名片领取源码 环境使用 Python 3.8 Pycharm 模块使用 import requests import csv import datetime import hashlib import time 一. 数据来源分析 明确需求 明确采集网站以及数…

Linux Spug自动化运维平台公网远程访问

文章目录 前言1. Docker安装Spug2 . 本地访问测试3. Linux 安装cpolar4. 配置Spug公网访问地址5. 公网远程访问Spug管理界面6. 固定Spug公网地址 前言 Spug 面向中小型企业设计的轻量级无 Agent 的自动化运维平台&#xff0c;整合了主机管理、主机批量执行、主机在线终端、文件…

Unity HoloLens 2 应用程序发布

设置3D 启动器画面&#xff0c;glb格式的模型 VS中可以直接生成所有大小的图标

C++:快速入门篇

C:.cpp(面向对象) C语音&#xff1a;.c(面向过程)是为了弥补C的不足 命名冲突&#xff1a; 1.写的跟库冲突 2.自己写的互相冲突 1.命名空间 在C/C中&#xff0c;变量、函数和后面要学到的类都是大量存在的&#xff0c;这些变量、函数和类的名称将都存在于全局作用域中&#xff…

mysql扩展语句

&#xff08;一&#xff09;复制表和删除表 &#xff08;二&#xff09;临时表 &#xff08;三&#xff09;mysql的六种约束方式 主键约束 primary key 用于唯一标识表中的每一行&#xff0c;主键列的值必须是唯一而且不能为空&#xff0c;一个表只能有一个主键 外键约束 for…

mysql之语句

1、mysql的扩展语句 &#xff08;1&#xff09;创建表 if not exists yyy&#xff1a;这个表不存在才会创建 zerofill&#xff1a;自动补齐位置 primary key&#xff1a;当前表的主键&#xff0c;主键只能有一个&#xff0c;唯一且不能为空 auto_increment&#xff1a;表示…

Allegro172版本不显示Microvia间距规则的解决办法

Allegro172版本不显示Microvia间距规则的解决办法 在用Allegro进行PCB设计的时候,进行盲埋孔单板设计的时候,有时会使用到Microvia,当然就要对Microvia进行规则设置,如下图 Allegro166版本的时候,Microvia规则是一直存在的 但是当版本升级到了172的时候,会发现Microvia的…

【面试专题】并发编程篇①

&#x1f4c3;个人主页&#xff1a;个人主页 &#x1f525;系列专栏&#xff1a;Java面试专题 1.线程和进程的区别 线程和进程都是操作系统中的概念&#xff0c;它们的主要区别如下&#xff1a; 资源分配&#xff1a;进程是操作系统中的资源分配的基本单位&#xff0c;每个进程…

IDEA优雅自动生成类注释和快捷键生成方法注释

生成类注释 Preferences->Editor->File and Code Templates-> Includes ->File Header 注释模板&#xff1a; /*** Classname ${NAME}* Description ${description}* Date ${DATE} ${TIME}* Created by ZouLiPing*/生成方法和字段注释 查看IDEA自动配置java快捷…

Istio实战(十)-Envoy 请求解析(上)

前言 Envoy 是一款面向 Service Mesh 的高性能网络代理服务。它与应用程序并行运行,通过以平台无关的方式提供通用功能来抽象网络。当基础架构中的所有服务流量都通过 Envoy 网格时,通过一致的可观测性,很容易地查看问题区域,调整整体性能。 Envoy也是istio的核心组件之一…

使用cpufrequtils查看调整cpu频率及模式

使用cpufrequtils查看调整cpu频率及模式 cpufrequtils是一个查看和修改CPU频率GHz的工具 有些物理服务器使用默认频率进行运行&#xff0c;这时可以使用该工具进行就该CPU的核心频率 安装: apt install cpufrequtils yum install cpufrequtils 使用: # 查看全部核心详细信息…

1111111111111

一、集合 1.1 简介 集合主要分为两组&#xff08;单列集合、双列集合&#xff09;&#xff0c;Collection 接口有两个重要的子接口 List 和Set&#xff0c;它们的实现子类都是单列集合。Map 接口的实现子类是双列集合&#xff0c;存放的是 K-V 1.2 关系图 二、Collection 接口…

Shadow DOM API 的 ShadowRoot 接口支持挂载的 shadow DOM 元素仅有18个:

<article, aside, blockquote, body, div, footer, h1-h6, header, main, nav, p, section, span> 浏览器兼容性 Browser compatibility

配置OSPF的多区域

实验6&#xff1a;配置多区域OSPF 实验需求 实现OSPF多区域配置阐明OSPF的LSA的类型阐明OSPF引入外部路由的配置方法阐明向OSPF引入缺省路由的方法 实验拓扑 配置多区域OSPF如图1-16所示。 图1-16 配置多区域OSPF 实验步骤 [1] IP地址配置 R1的配置 <Huawei>system…

Apache Doris (四十九): Doris表结构变更-动态分区(1)

🏡 个人主页:IT贫道_大数据OLAP体系技术栈,Apache Doris,Clickhouse 技术-CSDN博客 🚩 私聊博主:加入大数据技术讨论群聊,获取更多大数据资料。 🔔 博主个人B栈地址:豹哥教你大数据的个人空间-豹哥教你大数据个人主页-哔哩哔哩视频 目录

动态规划14:一和零

动态规划14&#xff1a;一和零 题目 474. 一和零 给你一个二进制字符串数组 strs 和两个整数 m 和 n 。 请你找出并返回 strs 的最大子集的长度&#xff0c;该子集中 最多 有 m 个 0 和 n 个 1 。 如果 x 的所有元素也是 y 的元素&#xff0c;集合 x 是集合 y 的 子集 。 …

计算机网络 第五章传输层

文章目录 1 传输层的功能2 传输层两种协议&#xff1a;UDP和TCP3 端口和端口号4 UDP数据报特点和首部格式5 UDP校验6 TCP协议的特点7 TCP报文段首部格式 1 传输层的功能 2 传输层两种协议&#xff1a;UDP和TCP 3 端口和端口号 4 UDP数据报特点和首部格式 5 UDP校验 6 TCP协议的…

机器人的触发条件有什么区别,如何巧妙的使用

简介​ 维格机器人触发条件,分为3个,分别是: 有新表单提交时、有记录满足条件时、有新的记录创建时 。 看似3个,其实是能够满足我们非常多的使用场景。 本篇将先介绍3个条件的触发条件,然后再列举一些复杂的触发条件如何用现有的触发条件来满足 注意: 维格机器人所有的…

ChatGLM系列四:P-Tuning微调

P-Tuning&#xff0c;参考ChatGLM官方代码 &#xff0c;是一种针对于大模型的soft-prompt方法 P-Tuning: 在输入的embedding层前&#xff0c;将prompt转换为可学习的额外一层embedding层. P-Tuning&#xff0c;仅对大模型的Embedding加入新的参数。 P-Tuning-V2&#xff0c;将…