IT🐶胶水Python

Conda安装jupyterlab-lsp后出现环境异常

2020-02-20  本文已影响0人  爱折腾的大懒猪

根据一个帖子的引导, 安装jupyterlab插件jupyterlab-lsp, 能够实现jupyterlab的一些基本IDE功能, 例如代码信息提示, 补全, 语法差错等等.

https://github.com/krassowski/jupyterlab-lsp

根据里面的安装需要, 需要安装nodejs, jupyter-lsp, 还有语言服务器(language-server), 没有最后者就没有相关功能, jupyter-lsp插件只是借用这个server来服务. 安装代码是:

conda install -c conda-forge python-language-server r-languageserver

使用起来算正常.

但今天突然发现, 命令行提示的服务器名变了:

另外, shell的启动变得很慢, 要等待几秒.

好生奇怪, 用这个x86_64-conda_cos6-linux-gnu去连同hostname 进行搜索, 没找到相关问题.

export | grep conda发现, 设置了一大堆相关的环境变量!! 包括HOST变了, GCC等编译器环境变量那些都变了!

$ export | grep conda                                                
ADDR2LINE=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-addr2line
AR=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-ar
AS=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-as
CC=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-cc
CFLAGS='-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
CMAKE_PREFIX_PATH=/home/hom/Softwares/miniconda3:/home/hom/Softwares/miniconda3/x86_64-conda_cos6-linux-gnu/sysroot/usr
CONDA_BACKUP_HOST=x86_64-conda_cos6-linux-gnu
CONDA_BACKUP_LDFLAGS='-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/hom/Softwares/miniconda3/lib -Wl,-rpath-link,/home/hom/Softwares/miniconda3/lib -L/home/hom/Softwares/miniconda3/lib'
CONDA_BUILD_SYSROOT=/home/hom/Softwares/miniconda3/x86_64-conda_cos6-linux-gnu/sysroot
CONDA_EXE=/home/hom/Softwares/miniconda3/bin/conda
CONDA_PREFIX=/home/hom/Softwares/miniconda3
CONDA_PYTHON_EXE=/home/hom/Softwares/miniconda3/bin/python
CPP=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-cpp
CPPFLAGS='-DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /home/hom/Softwares/miniconda3/include'
CXX=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++
CXXFILT=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-c++filt
CXXFLAGS='-fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
DEBUG_CFLAGS='-march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
DEBUG_CPPFLAGS='-D_DEBUG -D_FORTIFY_SOURCE=2 -Og -isystem /home/hom/Softwares/miniconda3/include'
DEBUG_CXXFLAGS='-fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fvar-tracking-assignments -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
DEBUG_FFLAGS='-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe'
DEBUG_FORTRANFLAGS='-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include -fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-all -fno-plt -Og -g -Wall -Wextra -fcheck=all -fbacktrace -fimplicit-none -fvar-tracking-assignments -ffunction-sections -pipe'
ELFEDIT=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-elfedit
F77=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran
F90=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran
F95=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-f95
FC=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran
FFLAGS='-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
FORTRANFLAGS='-fopenmp -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/hom/Softwares/miniconda3/include'
GCC=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gcc
GCC_AR=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gcc-ar
GCC_NM=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gcc-nm
GCC_RANLIB=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gcc-ranlib
GFORTRAN=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gfortran
GPROF=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-gprof
GXX=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-g++
HOST=x86_64-conda_cos6-linux-gnu
LD=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-ld
LDFLAGS='-Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,-rpath,/home/hom/Softwares/miniconda3/lib -Wl,-rpath-link,/home/hom/Softwares/miniconda3/lib -L/home/hom/Softwares/miniconda3/lib'
LD_GOLD=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-ld.gold
NM=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-nm
OBJCOPY=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-objcopy
OBJDUMP=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-objdump
PATH=/home/hom/Softwares/miniconda3/bin:/home/hom/Softwares/miniconda3/condabin:/usr/local/cuda-10.1/bin:/home/hom/local/bin:/usr/local/Modules/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
RANLIB=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-ranlib
READELF=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-readelf
RSTUDIO_WHICH_R=/home/hom/Softwares/miniconda3/bin/R
SIZE=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-size
STRINGS=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-strings
STRIP=/home/hom/Softwares/miniconda3/bin/x86_64-conda_cos6-linux-gnu-strip
_CONDA_PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_x86_64_conda_cos6_linux_gnu

这问题就老大了, 会导致严重的问题.

查看了shell的启动脚本, 没有什么相关改动, 很可能是conda 启动的设置问题, 启动脚本有以下一段:

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!

__conda_setup="$('/home/hom/Softwares/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/hom/Softwares/miniconda3/etc/profile.d/conda.sh" ]; then
        . "/home/hom/Softwares/miniconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/hom/Softwares/miniconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

经注释发现, 注释掉eval "$__conda_setup" 重新开一个shell tab就不会出现问题. 就是conda的锅!

怀疑时昨天安装的东东的问题, 经查, 最可疑就是上面那个server的问题.

把他们卸载了, 问题就解决了:

conda remove python-language-server r-languageserver

查看昨天的安装和今天的卸载, 发现conda安装了gcc等编译器:

image.png

卸载时会把相关东写卸载掉, 然后一切就正常了. 重新安装pyhon server

conda install python-language-server

OK, 一切正常.

一个可能的原因是, 安装r-languageserver 时需要依赖R. 而安装这玩意可能要底层编译器, 因此就擅作主张自己装了一堆编译器并改变了环境变量. NND.

建议需要安装的朋友, 别使用r-languageserver (或者事先安装好R, 可能就没这个问题了)

上一篇下一篇

猜你喜欢

热点阅读