英文:
Conda environments are no longer isolated
问题
Anaconda在我的Ubuntu服务器上完全崩溃了。在任何conda环境中,我至少可以导入我在我的基础环境中安装的所有包。例如,我有一个来自我公司私有GitHub存储库的ctha_xml
包。我可以运行:
conda create -n foo python=3.9
conda activate foo
python
>>> import ctha_xml
它可以工作,因为ctha_xml
已安装在我的基础环境中。这适用于我基础环境中的所有包以及除基础外的所有环境。
我该如何解决这个问题?这可能是我的环境变量或.bashrc
文件出了问题吗?
os.environ
在一个名为text-generation-client
的conda环境中的示例如下:
environ{'SHELL': '/bin/bash',
...
...
'CONDA_PROMPT_MODIFIER': '(text-generation-client) ',
...
...
'CONDA_DEFAULT_ENV': 'text-generation-client',
...
...
'PATH': '/home/holmes/.conda/envs/text-generation-client/bin:/opt/conda/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/holmes/bin',
...
...
'ctha_xml.__file__': '/home/holmes/.local/lib/python3.10/site-packages/ctha_xml/__init__.py'
...
...
}
英文:
Anaconda has become completely broken on my Ubuntu server. In any conda environment, I can import packages all that I installed in my base environment, at a minimum. For example I have a package ctha_xml
that comes from a private GitHub repository belonging to my company. I can run:
conda create -n foo python=3.9
conda activate foo
python
>>> import ctha_xml
and it works, because ctha_xml
is installed in my base environment. This applies to all packages in my base environment, and all environments besides base.
What can I do to fix this? Could this be something wrong with my environment variables or my .bashrc
?
os.environ
inside a conda environment called text-generation-client
looks like this:
environ{'SHELL': '/bin/bash',
'CONDA_EXE': '/opt/conda/bin/conda',
'_CE_M': '',
'PWD': '/home/holmes',
'LOGNAME': 'holmes',
'XDG_SESSION_TYPE': 'tty',
'CONDA_PREFIX': '/home/holmes/.conda/envs/text-generation-client',
'MOTD_SHOWN': 'pam',
'HOME': '/home/holmes',
'LANG': 'C.UTF-8',
'LS_COLORS': 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:',
'CONDA_PROMPT_MODIFIER': '(text-generation-client) ',
'LC_TERMINAL': 'iTerm2',
'SSH_CONNECTION': '10.159.5.25 44390 10.60.244.9 22',
'LESSCLOSE': '/usr/bin/lesspipe %s %s',
'XDG_SESSION_CLASS': 'user',
'TERM': 'xterm-256color',
'_CE_CONDA': '',
'LESSOPEN': '| /usr/bin/lesspipe %s',
'USER': 'holmes',
'CONDA_SHLVL': '2',
'LC_TERMINAL_VERSION': '3.4.19',
'SHLVL': '1',
'XDG_SESSION_ID': '2383',
'CONDA_PYTHON_EXE': '/opt/conda/bin/python',
'XDG_RUNTIME_DIR': '/run/user/1001',
'SSH_CLIENT': '10.159.5.25 44390 22',
'CONDA_DEFAULT_ENV': 'text-generation-client',
'XDG_DATA_DIRS': '/usr/local/share:/usr/share:/var/lib/snapd/desktop',
'PATH': '/home/holmes/.conda/envs/text-generation-client/bin:/opt/conda/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/holmes/bin',
'DBUS_SESSION_BUS_ADDRESS': 'unix:path=/run/user/1001/bus',
'SSH_TTY': '/dev/pts/8',
'CONDA_PREFIX_1': '/opt/conda',
'_': '/home/holmes/.conda/envs/text-generation-client/bin/ipython',
'KMP_DUPLICATE_LIB_OK': 'True',
'KMP_INIT_AT_FORK': 'FALSE'}
ctha_xml.__file__
indicates that it is being loaded from
/home/holmes/.local/lib/python3.10/site-packages/ctha_xml/__init__.py
答案1
得分: 2
根据这个GitHub问题,我了解到可以运行以下命令来解决这个问题:
conda install -c conda-forge conda-ecosystem-user-package-isolation
之后,您需要停用然后重新启用您的环境,否则将无法导入任何包。也可以设置PYTHONNOUSERSITE=1
,但这会干扰基本环境,如果全局设置它的话。
我仍然不明白为什么这种行为突然开始发生,而之前没有发生,或者为什么conda在每个新环境上不执行我提到的操作的等效操作,但在每个环境上安装一个包的工作量非常小,所以我对这个解决方案感到满意。
英文:
Based on this GitHub issue, I learned that I can run
conda install -c conda-forge conda-ecosystem-user-package-isolation
to solve this problem. You will need to deactivate and activate your environment afterwards, or you will not be able to import any packages. One can also set PYTHONNOUSERSITE=1
, but that messes up the base environment if you set it globally.
I still don't understand why this behavior suddenly started happening when it wasn't happening before, or why conda doesn't do the equivalent of the operation I mentioned on every new environment, but the effort of installing one package on each environment is very minimal, so I'm happy with this solution.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论