使用pip在mac osx上安装python模块

时间:2015-02-14 04:26:36

标签: python macos pip shopify .bash-profile

我有一个关于在OS X上安装Python模块的标准问题。我读过并尝试过的解决方案无效。

基本情况: 我有一个非常新鲜的mac基本上,到目前为止,没有安装额外的包。我安装了Python 2.7和pip,现在我试图使用ShopifyAPI模块让Python工作。 (我决定彻底安装python,这样我就不会干扰预装的osx版本。)


采取的步骤:

  1. 已安装python-2.7.9-macosx10.6.pkg。我可以在我的Applications目录下看到安装。
  2. 通过Finder点击Update Shell Profile.command
  3. 在终端
  4. 中启用python get-pip.py
  5. 在终端
  6. 中安装了带python -m pip install ShopifyAPI的Shopify API
  7. python testshop抛出错误:

    Traceback (most recent call last):
    File "testshop.py", line 1, in <module>
        import shopify
    ImportError: No module named shopify_api
    

  8. 其他成果:

    1. python举报Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
    2. 我的.bash_profile是

      #Setting PATH for Python 2.7
      #The original version is saved in .bash_profile.pysave
      PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
      export PATH
      
    3. /Library/Frameworks/Python.framework/Versions/2.7/bin的内容如下:

      drwxrwxr-x  35 root      admin   1190 Feb 13 17:36 .
      drwxrwxr-x  10 root      admin    340 Feb 13 07:27 ..
      lrwxr-xr-x   1 root      admin      6 Feb 13 07:27 2to3 -> 2to3-2
      lrwxr-xr-x   1 root      admin      8 Feb 13 07:27 2to3-2 -> 2to3-2.7
      -rwxrwxr-x   1 root      admin    140 Dec 10 10:13 2to3-2.7
      -rwxrwxr-x   1 root      admin    309 Feb 13 07:27 easy_install
      -rwxrwxr-x   1 root      admin    309 Feb 13 07:27 easy_install-2.7
      lrwxr-xr-x   1 root      admin      5 Feb 13 07:27 idle -> idle2
      lrwxr-xr-x   1 root      admin      7 Feb 13 07:27 idle2 -> idle2.7
      -rwxrwxr-x   1 root      admin    138 Dec 10 10:13 idle2.7
      -rwxr-xr-x   1 me        admin    281 Feb 13 08:48 pip
      -rwxr-xr-x   1 me        admin    281 Feb 13 08:48 pip2
      -rwxr-xr-x   1 me        admin    281 Feb 13 08:48 pip2.7
      lrwxr-xr-x   1 root      admin      6 Feb 13 07:27 pydoc -> pydoc2
      lrwxr-xr-x   1 root      admin      8 Feb 13 07:27 pydoc2 -> pydoc2.7
      -rwxrwxr-x   1 root      admin    123 Dec 10 10:13 pydoc2.7
      lrwxr-xr-x   1 root      admin      7 Feb 13 07:27 python -> python2
      lrwxr-xr-x   1 root      admin     10 Feb 13 07:27 python-32 -> python2-32
      lrwxr-xr-x   1 root      admin     14 Feb 13 07:27 python-config -> python2-config
      lrwxr-xr-x   1 root      admin      9 Feb 13 07:27 python2 -> python2.7
      lrwxr-xr-x   1 root      admin     12 Feb 13 07:27 python2-32 -> python2.7-32
      lrwxr-xr-x   1 root      admin     16 Feb 13 07:27 python2-config -> python2.7-config
      -rwxrwxr-x   1 root      admin  25624 Dec 10 10:13 python2.7
      -rwxrwxr-x   1 root      admin  13928 Dec 10 10:13 python2.7-32
      -rwxrwxr-x   1 root      admin   1726 Dec 10 10:13 python2.7-config
      lrwxr-xr-x   1 root      admin      8 Feb 13 07:27 pythonw -> pythonw2
      lrwxr-xr-x   1 root      admin     11 Feb 13 07:27 pythonw-32 -> pythonw2-32
      lrwxr-xr-x   1 root      admin     10 Feb 13 07:27 pythonw2 -> pythonw2.7
      lrwxr-xr-x   1 root      admin     13 Feb 13 07:27 pythonw2-32 -> pythonw2.7-32
      -rwxrwxr-x   1 root      admin  25624 Dec 10 10:13 pythonw2.7
      -rwxrwxr-x   1 root      admin  13928 Dec 10 10:13 pythonw2.7-32
      -rwxr-xr-x   1 me        admin   8751 Feb 13 08:50 shopify_api.py
      lrwxr-xr-x   1 root      admin      9 Feb 13 07:27 smtpd.py -> smtpd2.py
      -rwxrwxr-x   1 root      admin  18586 Dec 10 10:13 smtpd2.7.py
      lrwxr-xr-x   1 root      admin     11 Feb 13 07:27 smtpd2.py -> smtpd2.7.py
      

    4. bash配置文件对我来说似乎很奇怪,我相信只有Update Shell Profile.command才会改变它。 .bash_profile.pysave.bash_profile提到的~不存在/Library/Frameworks/Python.framework/Versions/Current/bin/python2.7 testshop

      我尝试过的其他内容并且从python收到了相同的导入错误:

      1. 正在运行"/Library/Frameworks/Python.framework/Versions/Current/bin"
      2. 在bash_profile中创建并设置PYTHONPATH python testshop并运行{{1}}

0 个答案:

没有答案