conda 环境名丢失

conda environments:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
                     /home/fjx/ENTER
/home/fjx/ENTER/envs/bio
/home/fjx/ENTER/envs/hicexplore
base * /home/fjx/ENTER/envs/juicer
HiCLift /home/fjx/ENTER/envs/juicer/envs/HiCLift
/home/fjx/ENTER/envs/mcool
/home/fjx/ENTER/envs/yolov8

(pfld) 。。。。。$ conda env list
# conda environments:
#
/home/deeplearning/anaconda3/home/deeplearning/anaconda3/envs/common/home/deeplearning/anaconda3/envs/openface
/home/deeplearning/anaconda3/envs/pfld
/home/deeplearning/anaconda3/envs/public_env
。。。。。。
base /home/deeplearning/miniconda3
pfld * /home/deeplearning/miniconda3/envs/pfld

(pfld) 。。。。。$ conda activate public_env

EnvironmentNameNotFound: Could not find conda environment: public_env
You can list all discoverable environments with `conda info --envs`.
  • 解决
1
2
3
4
● 激活到base环境根据路径,然后source activate  conda env list
● (pfld) 。。。。。。$ conda activate /home/deeplearning/anaconda3
(/home/deeplearning/anaconda3) 。。。。。。$ source activate
(/home/deeplearning/anaconda3) 。。。。。。$ conda env list

conda environments:

base * /home/deeplearning/anaconda3
common /home/deeplearning/anaconda3/envs/common
openface /home/deeplearning/anaconda3/envs/openface
pfld /home/deeplearning/anaconda3/envs/pfld
public_env /home/deeplearning/anaconda3/envs/public_env/home/deeplearning/miniconda3
/home/deeplearning/miniconda3/envs/pfld

疑似安装频道不同问题

  • 疑似安装频道不同问题
1
2
3
4
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Solving environment: unsuccessful attempt using repodata from current_repodata.json, retrying with next repodata source.
Collecting package metadata (repodata.json): | Killed
  • 描述,首先是安装mamba等库出现错误,部分生物信息的库也装不上
  • 解决方法:开全局代理无用,新建环境没用

conda问题

conda config –remove-key channels # 恢复默认源文件

安装mamba

  • 出现unsuccessfully的提示,可以等一会,等一会之后就好了
  • mamba install出现lib错误,是缺少一个包,可以首先使用 docker list mamba查看Undefined symbol: archive_write_add_filter_zstd
1
2
3
4
5
6
7
> conda list mamba
# packages in environment at /users/blissadm/conda/miniconda/envs/foo:
#
# Name Version Build Channel
libmamba 0.24.0 hd8a31e3_1 conda-forge
libmambapy 0.24.0 py37h1ee4b26_1 conda-forge
mamba 0.24.0 py37h6dacc13_1 conda-forge
  • 然后再安装剩下来的那个包
1
conda install libarchive==3.5.2 -c conda-forge

Make 问题

makefile学习详见linux详解

1
2
Makefile:142: htscodecs.mk: No such file or directory
config.mk:2: *** Resolve configure error first. Stop.

root用户无法运行安装在用户目录下的conda

这个可能会遇到,,也说下解决方案吧,装在了普通用户下,环境都配好了,结果需要sudo权限运行脚本,而切换root之后,哪怕你给的anaconda的绝对路径跑,依然会找不到很多包,因为缺乏很多路径变量,所以要解决这个问题,办法在于给root用户添加环境变量,直接在root用户下运行即可:

sudo su #切换得到root用户下

#执行conda添加环境变量

/home/xxx/anaconda3/bin/conda init bash

conda 更换频道

1
2
3
4
5
6
7
8
9
## 添加channel
conda config --add channels bioconda
conda config --add channels conda-forge # conda-forge包含许多bioconda中尚不存在的包
conda config --set show_channel_urls yes # 显示软件来源于哪个channel
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes

File not valid,file size doesn’t match expectation

Extracting [> ] (–:–)

ERROR File not valid: file size doesn’t match expectation “/usr/local/miniconda3/pkgs/_libgcc_mutex-0.1-conda_forge.tar.bz2”

Expected: 2562

重新建一个环境直接在创建的时候给定要安装的东西,比如bwa和samtools

Pip太慢

换成阿里云之后仍然太慢,慢则求变

1
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/web/simple

共享服务器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Traceback (most recent call last):
File "yolo_debug.py", line 1, in <module>
from ultralytics import YOLO
File "/root/yolov8/ultralytics/__init__.py", line 5, in <module>
from ultralytics.hub import start
File "/root/yolov8/ultralytics/hub/__init__.py", line 5, in <module>
from ultralytics.hub.auth import Auth
File "/root/yolov8/ultralytics/hub/auth.py", line 5, in <module>
from ultralytics.hub.utils import HUB_API_ROOT, PREFIX, request_with_credentials
File "/root/yolov8/ultralytics/hub/utils.py", line 14, in <module>
from ultralytics.yolo.utils import (ENVIRONMENT, LOGGER, ONLINE, RANK, SETTINGS, TESTS_RUNNING, TQDM_BAR_FORMAT,
File "/root/yolov8/ultralytics/yolo/__init__.py", line 3, in <module>
from . import v8
File "/root/yolov8/ultralytics/yolo/v8/__init__.py", line 3, in <module>
from ultralytics.yolo.v8 import classify, detect, pose, segment
File "/root/yolov8/ultralytics/yolo/v8/classify/__init__.py", line 3, in <module>
from ultralytics.yolo.v8.classify.predict import ClassificationPredictor, predict
File "/root/yolov8/ultralytics/yolo/v8/classify/predict.py", line 5, in <module>
from ultralytics.yolo.engine.predictor import BasePredictor
File "/root/yolov8/ultralytics/yolo/engine/predictor.py", line 33, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory

经过python验证是importcv2的时候出现的问题,所以经过网上信息查询


sudo apt-get install libglib2.0-0
发现恒源云的sudo可以运行

所以改bug首先要从报错里面定义出重点区域,然后上网搜索,得到结果,多多尝试。

conda 导出环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
conda list -e > requirements.txt  #导出当前环境所有的依赖包及其对应的版本号
mamba install --yes --file requirements.txt #在新的环境中安装导出的包


import re
dependencies = """
- krb5=1.20.1=h81ceb04_0
- krbalancing=0.0.5=py39h1f90b4d_7
"""

pattern = r'^- (\w+)=([\d\.]+)=([\w\d]+)_(\d+)$'

for dep in dependencies.splitlines():
match = re.match(pattern, dep)
if match:
name, version, build, build_number = match.groups()
print(f'mamba install -y {name}={version}')