简体   繁体   English

conda 环境中的屏幕不使用 python PATH

[英]Screen inside conda environment doesn't use python PATH

I have a conda environment that is running python 3.10.5.我有一个运行 python 3.10.5 的 conda 环境。 It works on the terminal without screen.它在没有屏幕的终端上工作。 First I did首先我做了

conda deactivate

And conda info at this step shows:此步骤的conda info显示:

     active environment : base
    active env location : /home/myuser/anaconda3
            shell level : 1
       user config file : /home/myuser/.condarc
 populated config files : 
          conda version : 4.13.0
    conda-build version : 3.21.8
         python version : 3.9.12.final.0
       virtual packages : __cuda=10.2=0
                          __linux=5.4.0=0
                          __glibc=2.27=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/myuser/anaconda3  (writable)
      conda av data dir : /home/myuser/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/myuser/anaconda3/pkgs
                          /home/myuser/.conda/pkgs
       envs directories : /home/myuser/anaconda3/envs
                          /home/myuser/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.4.0-109-generic ubuntu/18.04.6 glibc/2.27
                UID:GID : 1001272705:1000000513
             netrc file : None
           offline mode : False

then I did然后我做了

screen -S scren_name

and the conda info at this step is这一步的conda info

     active environment : base
    active env location : /home/myuser/anaconda3
            shell level : 1
       user config file : /home/myuser/.condarc
 populated config files : 
          conda version : 4.13.0
    conda-build version : 3.21.8
         python version : 3.9.12.final.0
       virtual packages : __cuda=10.2=0
                          __linux=5.4.0=0
                          __glibc=2.27=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/myuser/anaconda3  (writable)
      conda av data dir : /home/myuser/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/myuser/anaconda3/pkgs
                          /home/myuser/.conda/pkgs
       envs directories : /home/myuser/anaconda3/envs
                          /home/myuser/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.4.0-109-generic ubuntu/18.04.6 glibc/2.27
                UID:GID : 1001272705:1000000513
             netrc file : None
           offline mode : False

then I activated the environment in screen.然后我在屏幕中激活了环境。 Now conda info says现在conda info

     active environment : catvehicle
    active env location : /home/myuser/anaconda3/envs/catvehicle
            shell level : 2
       user config file : /home/myuser/.condarc
 populated config files : 
          conda version : 4.13.0
    conda-build version : 3.21.8
         python version : 3.9.12.final.0
       virtual packages : __cuda=10.2=0
                          __linux=5.4.0=0
                          __glibc=2.27=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/myuser/anaconda3  (writable)
      conda av data dir : /home/myuser/anaconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/myuser/anaconda3/pkgs
                          /home/myuser/.conda/pkgs
       envs directories : /home/myuser/anaconda3/envs
                          /home/myuser/.conda/envs
               platform : linux-64
             user-agent : conda/4.13.0 requests/2.27.1 CPython/3.9.12 Linux/5.4.0-109-generic ubuntu/18.04.6 glibc/2.27
                UID:GID : 1001272705:1000000513
             netrc file : None
           offline mode : False

However, when I write python in screen, the version shown is the default Ubuntu 18.04 included python which is 2.7, and not the 3.10.5 version that was part of my conda env.但是,当我在屏幕上编写python时,显示的版本是默认的 Ubuntu 18.04 包含的 python 2.7,而不是我的 conda env 中的 3.10.5 版本。

how can I fix this, or make it use the proper python?我该如何解决这个问题,或者让它使用正确的python?

Edit: as mentioned by other users, setting an alias is not recommended.编辑:正如其他用户所提到的,不建议设置别名。 I was able to fix it by:我能够通过以下方式修复它:

  1. Entering screen进入画面
  2. Writing conda deactivate until the (base) environment was no longer activated either.编写conda deactivate直到(base)环境也不再被激活。
  3. Writing conda activate my_env to activate.编写conda activate my_env来激活。

Now the python path is correct.现在python路径是正确的。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python 解释器(VScode)“激活”一个 conda 环境,但环境没有改变 - Python interpreter (VScode) "activates" a conda environment, but the environment doesn't change VSCode集成终端不使用Conda环境执行python文件 - VSCode integrated terminal doesn't use Conda environment to execute python files 如何使用当前conda环境的python的路径作为脚本的shebang? - How to use path of current conda environment's python as shebang for a script? 如何设置要在 python 脚本中使用的 conda 环境 - How to set the conda environment to use inside a python script 命令行不使用 conda 环境中的 python 即使它处于活动状态,可能是 .bash_profile 中的问题? - Command line doesn't use python from conda environment even though it's active, maybe problem in .bash_profile? PyCharm 终端没有激活conda环境 - PyCharm terminal doesn't activate conda environment 在 Conda 环境中使用 pip package - Use pip package inside Conda environment Python不在conda环境中时不导入文件 - Python not importing files when not inside conda environment 无法在 conda 环境中访问 activate、deactivate 或 conda - Can't access activate, deactivate, or conda inside a conda environment 我大学的集群无法连接到互联网,因此我无法使用conda来使用python 2.7创建环境。 我还可以做些什么? - My university's cluster doesn't connect to the internet, so I can't use conda to create an environment with python 2.7. What else can I do?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM