conda测试与理解 | conda中的perl编译的模块能

2022-06-04  本文已影响0人  学生信的大叔

前言

我有时候会用到conda-pack来打包并迁移环境。前几天用conda下perl编译了下File::CountLines模块,这个模块也自动安装到了conda环境下。当时有点好奇,这个模块在conda-pack打包时是否会受到影响,今天测试下。

由于本人能力有限,描述可能有不当或者错误的地方,请仔细辨别后使用。

下面代码中$ 后的为linux命令行,其它为命令行结果。需要注意的是,下面命令行中不是所有命令都贴了运行结果。

相关推文:

conda-pack的使用:我的conda常用命令、报错解决与技巧记录conda-pack完成环境迁移部分

新建环境运行

注意#后的注释

$ conda create -n test -c conda-forge perl conda-pack -y
$ which perl #确认是调用的test环境下的perl
/home/zheng/anaconda3/envs/test/bin/perl
$ conda env list
# conda environments:
#
base                     /home/zheng/anaconda3
test                  *  /home/zheng/anaconda3/envs/test
$ git clone git://github.com/moritz/File-CountLines.git
$ cd File-CountLines/
$ perl Makefile.PL 
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for File::CountLines
Writing MYMETA.yml and MYMETA.json

$ make
cp lib/File/CountLines.pm blib/lib/File/CountLines.pm
Manifying 1 pod document

$ make install 
Installing /home/zheng/anaconda3/envs/test/lib/perl5/site_perl/File/CountLines.pm
Installing /home/zheng/anaconda3/envs/test/man/man3/File::CountLines.3
Appending installation info to /home/zheng/anaconda3/envs/test/lib/perl5/5.32/core_perl/perllocal.pod
#从这里的路径看是安装到了环境test的路径下。
$ conda pack -n test -o test.tar.gz #打包环境进行迁移

迁移后测试

将打包好的环境test.tar.gz 上传到服务器上。

$ mkdir test && cd test #上传到test文件夹中
$ tar -zxvf test.tar.gz
$ source bin/activate  #激活环境
$ perl run_count_lines.pl 

遇到的报错

这里是没有执行conda-pack的,因为我执行conda-pack的时候报错了。报错内容也无发现。

如下,

Traceback (most recent call last):
  File "/home/data/vipxxtxx/workspace/test2/bin/conda-unpack", line 479, in <module>
    update_prefix(os.path.join(new_prefix, path), new_prefix,
  File "/home/data/vipxxtxx/workspace/test2/bin/conda-unpack", line 66, in update_prefix
    with open(path, 'rb+') as fh:
PermissionError: [Errno 13] Permission denied: '/home/data/vipxxtxx/workspace/test2/man/man3/File::CountLines.3'

这里将/home/data/vipxxtxx/workspace/test2/man/man3/File::CountLines.3 权限改为777也不行。

另外,测试的时候还发现,解压test.tar.gz不允许虚拟机上在Ubuntu与windows共享文件夹内进行,一些链接不允许创建。

小结

经过初步判断,conda-pack不能完美打包conda下的perl编译的模块。可用,但是会有报错。

上一篇 下一篇

猜你喜欢

热点阅读