python 我如何在miniconda中重新编译conda、activate和deactivate命令?

t3irkdon  于 2022-12-21  发布在  Python
关注(0)|答案(1)|浏览(69)

由于一些奇怪的原因,当我重新登录到集群/HPC时,我使用的conda、activate和deactivate命令停止工作。我打印了它们应该在的位置,但它们不在那里,而是.c~文件在那里,不再是bin:

brando9~/miniconda/bin $ ls
2to3          certtool                c_rehash         genrb             img2webp           lzfgrep             pip3.10           raw2tiff          tiffcp      unzstd                          xzegrep
2to3-3.9      chardetect              cwebp            gif2rgb           infocmp            lzgrep              pip3.9            rdjpgcom          tiffcrop    wandb                           xzfgrep
activate.c    cjpeg                   deactivate.c     gif2webp          infotocap          lzless              pkcs1-conv        reset             tiffdither  wb                              xzgrep
bsdcat        clear                   derb             gifbuild          jpegtran           lzma                pkgdata           rg                tiffdump    webpinfo                        xzless
bsdcpio       conda-build             djpeg            gifclrmp          jpgicc             lzmadec             pkginfo           sexp-conv         tiffinfo    webpmux                         xzmore
bsdtar        conda.c~                dwebp            giffix            lame               lzmainfo            pngfix            shortuuid         tiffmedian  wish                            zstd
bunzip2       conda-convert           f2py             giftext           libdeflate-gunzip  lzmore              png-fix-itxt      sqlite3           tiffset     wish8.6                         zstdcat
bzcat         conda-debug             f2py3            giftool           libdeflate-gzip    makeconv            ppm2tiff          sqlite3_analyzer  tiffsplit   wrjpgcom                        zstdgrep
bzcmp         conda-develop           f2py3.9          gnutls-cli        libpng16-config    ncursesw6-config    psicc             srptool           tificc      x86_64-conda_cos7-linux-gnu-ld  zstdless
bzdiff        conda-env.c~            fax2ps           gnutls-cli-debug  libpng-config      nettle-hash         psktool           tabs              toe         x86_64-conda-linux-gnu-ld       zstdmt
bzegrep       conda-index             fax2tiff         gnutls-serv       linkicc            nettle-lfib-stream  pydoc             tclsh             torchrun    xml2-config
bzfgrep       conda-inspect           ffmpeg           h264dec           lz4                nettle-pbkdf2       pydoc3            tclsh8.6          tput        xmlcatalog
bzgrep        conda-metapackage       ffprobe          h264enc           lz4c               normalizer          pydoc3.9          tic               tqdm        xmllint
bzip2         conda-render            freetype-config  iconv             lz4cat             ocsptool            python            tiff2bw           transicc    xz
bzip2recover  conda-skeleton          genbrk           icu-config        lzcat              openssl             python3           tiff2pdf          tset        xzcat
bzless        convert-caffe2-to-onnx  gencfu           icuinfo           lzcmp              pal2rgb             python3.9         tiff2ps           unlz4       xzcmp
bzmore        convert-onnx-to-caffe2  gencnval         idle3             lzdiff             patch               python3.9-config  tiff2rgba         unlzma      xzdec
captoinfo     cph                     gendict          idle3.9           lzegrep            patchelf            python3-config    tiffcmp           unxz        xzdiff

我尝试重命名文件以删除波浪号~,并使用gcc -Wall activate.c -o activate为三个C文件中的每个文件重新编译,但失败了,显示以下消息:

brando9~/miniconda/bin $ gcc -Wall activate.c -o activate
activate.c:1:2: error: invalid preprocessing directive #!
 #!/bin/sh
  ^
activate.c:2:1: warning: data definition has no type or storage class
 _CONDA_ROOT="/dfs/scratch0/brando9/miniconda"
 ^
activate.c:2:1: warning: type defaults to ‘int’ in declaration of ‘_CONDA_ROOT’ [-Wimplicit-int]
activate.c:3:3: error: invalid preprocessing directive #Copyright
 # Copyright (C) 2012 Anaconda, Inc
   ^
activate.c:4:3: error: invalid preprocessing directive #SPDX
 # SPDX-License-Identifier: BSD-3-Clause
   ^
activate.c:5:1: error: stray ‘\’ in program
 \. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
 ^
activate.c:5:4: error: expected identifier before string constant
 \. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
    ^

我试着捕获我在wget wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh中使用的install.sh文件,但输出不可读:

...
m�gI���w%��.{=[��M7O�<��R��yj#���#K��r�q�m���V)=��O���?�˳�����MU���i2|I%�D�h�E:���/C�                         �l>��pD�Y����w��i#��X�eT��eҠ����Grq����X*9l���dW
 �~����q�NyF?�_EbE��׳B&���>�Kw5nZ!~ʒ6m�ˡ�����ǟ�� �nX�г]1��R���S 3�}��<Z���En%'��tS�}�;�G7sFi�[��N3�W34<>[�h����M~�1�T�� {&��>H:�Eo �~��Pp�*��%�Օ�           �d��H�W��H�7����~h�2�V[Iў��5O�H&�\�u�
                                                                                                                                                                                                    u�ZD��Y[d�
                                                                                                                                                                                                              ��s*�%�u�j�     y\AB�����              ��qnm/5��j@k����<Z�s3�y*�i����NO�4&��~�邲�W�S��גDY��{�G���8�[���H�?��������H�e+ix�16-�yYI�܉{�j2��P�D�����ڬ��k^��=M��+ɓ�_p�!����k+!�U���B[nj�]nL�
                                                                                                                        �/5�5X&��0*:�{�=SJ\I�Z}�;?�d��6�[/�JOn'��G����X���5J���K�P��6>e�!����`*�޿��ěX2ؓ�3��h!�#�qП�R}P�1�ï�)=�U¶#|�G�^C

在这一点上,我决定我不知道发生了什么事,也不知道该如何修复它。当然,我的路径是好的,因为其他问题,所以建议修复Conda command not found。在这一点上,我决定我不知道发生了什么事,也不知道如何修复它了。任何帮助,不需要一个小时长的重新安装康达?
相关:

ryoqjall

ryoqjall1#

bin/activatebin/deactivate文件从来都不是二进制文件,而是简单的shell脚本。所描述的情况似乎表明,不知何故,.c被附加到文件名。看起来,您可以简单地重命名它们(删除.c),它们将恢复正常功能。
以下是我的版本,以供参考:

$ cat ${CONDA_PREFIX}/bin/activate
#!/bin/sh
_CONDA_ROOT="/Users/mfansler/mambaforge-arm64"
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$@"

这看起来基本上与gcc在OP中发出的activate.c文件的行相同(直到路径)。
然而,我注意到使用bin/activate已经过时了,AFAIK。从Conda v4.6开始,conda (de|)activate就变成了shell functions defined by conda shell.posix hookbin/activate文件中的代码是运行conda init一次(通常在安装时)后用户shell中已经提供的代码的重述。

相关问题