如何在HDInsight PySpark Jupyter笔记本中安装psycopg2

时间:2016-09-07 13:49:15

标签: python azure psycopg2 jupyter hdinsight

我需要"导入psycopg2"作为我的PySpark脚本的一部分。

根据documentation

  

!pip install   psycopg2

但是这会导致语法错误(就像任何!命令一样)。

我能够在/ usr / bin / anaconda / bin / python的SSH会话中安装,但看起来Jupyter可能正在使用不同的不同环境?

我甚至试过强迫

  

os.environ [" PYTHONPATH"]

在笔记本中没有运气,我的意思是笔记本电脑中的一个单元格:

  • 导入psycopg2会导致无法找到模块的错误
  • help(" modules")没有显示psycopg2
  • help(" modules psycopg2")会导致以下错误:
-lcutils

1 个答案:

答案 0 :(得分:0)

你输错了吗?你的文字是' pyscopg2'不是' psycopg2'

 public static  class CommonHelper
    {    
        public static SessionObjects sessionObjects
        {
            get
            {
                if ((HttpContext.Current.Session["sessionObjects"] == null))
                    HttpContext.Current.Session.Add("sessionObjects", new SessionObjects()); 
                return HttpContext.Current.Session["sessionObjects"] as SessionObjects;
            }
            set { HttpContext.Current.Session["sessionObjects"] = value; }
        }
    }

对于Python 3.5,Python已安装在Azure笔记本上。