未找到 Python pip 安装模块.如何将python链接到pip位置? [英] Python pip install module is not found. How to link python to pip location?

查看:24
本文介绍了未找到 Python pip 安装模块.如何将python链接到pip位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,我的项目需要 pySerial 和 feedparser 模块.我在跑山狮.

I'm a newbie and I needed the pySerial and feedparser module for my projects. I'm running Mountain lion.

我遵循了以下教程,以便我可以升级到 python 2.7.3,然后使用上述模块.

I followed the following tutorial so that I could upgrade to python 2.7.3 and then use the above mentioned modules.

http://hackercodex.com/guide/python-virtualenv-on-mac-osx-mountain-lion-10.8/

我一直在学习本教程,直到安装了 pip.而不是安装 Virtualenv.我使用以下命令安装pySerial和feedparser

I followed this tutorial till I installed pip. Instead of installing Virtualenv. I used the following commands to install pySerial and feedparser

$ pip install pySerial
Requirement already satisfied (use --upgrade to upgrade): pySerial in /Library/Python/2.7/site-packages
Cleaning up...

我认为这已经存在并检查了它.Python 似乎可以很好地导入它.我的 python 版本已经升级到 2.7.3 btw,因为我使用教程中提到的自制软件安装它.

I assumed that this was already present and checked it. Python seems to be importing this just fine. My python version has been upgraded to 2.7.3 btw since I installed it using homebrew as mentioned in the tutorial.

然后我尝试安装 feedparser

Then I tried installing feedparser

$ pip install feedparser
Requirement already satisfied (use --upgrade to upgrade): feedparser in /usr/local/lib/python2.7/site-packages
Cleaning up...

注意它在 usr/local/lib 中的 site-packages 目录中.

Notice how its in the site-packages directory in the usr/local/lib.

我所有的 pip 安装都安装在该目录中,但是当我尝试导入它们时,python 似乎没有找到它们.

All of my pip installs are being installed in that directory but python does not seem to be picking them up when i try importing them.

如何设置路径,以便 python 也能在核心目录中查找?

How do I set the path so that python also looks there as well as core directory?

非常感谢您的帮助.

我试着在这里寻找答案:​​Pip 安装但未找到模块为什么我使用 pip 和/或 easy_install 安装后,无法使用 python 2.7 在 mac 上导入 beautifulsoup?

I tried looking for answers here: Pip installs but module is not found Why I can't import beautifulsoup on mac using python 2.7 after installing it by using pip and/or easy_install?

但他们中没有一个和我的情况相同.我不明白为什么会发生这种情况,因为我使用以下内容编辑了我的 bash_profile

but niether of them are in the same situation as I am. I don't understand why this is happening as i edited my bash_profile with the following

# Set architecture flags
export ARCHFLAGS="-arch x86_64"
# Ensure user-installed binaries take precedence
export PATH=/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# Load .bashrc if it exists
test -f ~/.bashrc && source ~/.bashrc

然后安装homebrew,然后通过homebrew安装python 2.7.3(2.7.3目前在我的机器上运行)

then installed homebrew and then installed python 2.7.3 through homebrew (2.7.3 is now currently running on my machine)

我认为所有 pip 安装都会正确链接?

I figured all pip installs would be correctly linked?

推荐答案

作为一种快速的解决方法,假设您使用的是类似 bash 的终端 (Linux/OSX),您可以尝试导出 PYTHONPATH 环境变量:

As a quick workaround, and assuming that you are on a bash-like terminal (Linux/OSX), you can try to export the PYTHONPATH environment variable:

export PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages"

对于 Python 2.7

For Python 2.7

这篇关于未找到 Python pip 安装模块.如何将python链接到pip位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆