“导入xxx”不适用于jupyter笔记本,但适用于命令提示符

时间:2020-07-08 20:46:49

标签: python pyspark jupyter-notebook libraries

我正在尝试在jupyter-notebook上执行“导入pymongo”,但随后出现“没有名为pymongo的模块”错误。但是,当我在pyspark shell上“导入pymongo”时,效果很好。

我正在远程服务器上使用jupyter笔记本。

我的bash_profile看起来像这样:

  # .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

# User specific environment and startup programs

PATH=/opt/app/anaconda2/python27/bin/python2.7:$PATH:$HOME/bin
export PATH
export HADOOP_CONF_DIR=/etc/hadoop/conf
export MASTER="yarn"
export SPARK_MAJOR_VERSION=2
export SPARK_HOME=/usr/hdp/current/spark2-client
export PYSPARK_PYTHON=/opt/app/anaconda2/python27/bin/python2.7
export PYSPARK_DRIVER_PYTHON=/opt/app/anaconda2/python27/bin/python2.7
export PYTHONPATH=/opt/app/anaconda2/python27/bin/python2.7:$PYTHONPATH
export SPARK_LOCAL_DIRS=/opt/data/share05/sandbox/sandbox327/ly826p/sparklocaldir/

我的.bashrc看起来像这样:

# .bashrc
 
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
 
# User specific aliases and functions
 
##
# Java
##
 
# You need to make sure java 1.8 used for H2O work
 
export JAVA_HOME=/opt/app/java/jdk/jdk180
export PATH=$JAVA_HOME/bin:$PATH
 
 
##
# Python Anaconda
##
 
# This is where we force Linux to use your local install of Anaconda
# CHANGE THESE PATHS to match your sestup
#ANACONDA2_LOC=/opt/app/anaconda2/python27/bin/
ANACONDA2_LOC=/opt/data/share05/sandbox/sandbox327/ly826p/anaconda_installs/bin
ANACONDA2_PYTHON=${ANACONDA2_LOC}/ipython
export PATH="$ANACONDA2_LOC:$PATH"

我想知道是否是因为我在jupyter笔记本和命令提示符中使用了不同的python?

想知道如何解决该问题并使pymongo在我的jupyternotebook上工作。

0 个答案:

没有答案