本文介绍了OS X上的pip:已安装2.6 Python无法识别与pip2.6一起安装的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mac上使用Python 2.6.8和2.7.10(加上anaconda安装等),我需要安装 2.6.6 32位(长话),因此我从dmg.幸运的是,当我在shell中键入python2.6时,开始运行2.6. 6 解释器(尽管仅在该选项卡中,而不在其他选项卡中-也许很重要?).

With Python 2.6.8 and 2.7.10 (plus anaconda installs etc.) on my Mac, I needed to install 2.6.6 32-bit (long story), so I installed it from dmg. With luck, when I then typed python2.6 in a shell, the 2.6.6 interpreter started (though only in that tab, not in others - perhaps this is significant?).

然后,我需要安装一些模块,需要确保已为此新就地2.6.6安装了这些模块,而不是其他安装.因此,我采用了此处中概述的方法,即:

I then needed to install some modules, needing to make sure that they were got installed for this newly-in-place 2.6.6, not any other install. So I took the approach outlined here, namely:

sudo easy_install-2.6 pip

然后我使用pip2.6安装了所需的模块:

I then installed my desired module using pip2.6:

sudo pip2.6 install py2app==0.5.2

当我使用python2.6运行py2app时:

When I went to run py2app using python2.6:

python2.6 setup.py py2app

它抱怨没有安装setuptools.和以前一样,

It complained that setuptools was not installed. So as before,

sudo pip2.6 install setuptools

但再次:

MacBook-Pro-de-Pyderman:projet Pyderman$ python2.6 setup.py py2app
Traceback (most recent call last):
  File "setup.py", line 98, in <module>
    mac_setup()
  File "setup.py", line 46, in mac_setup
    from setuptools import setup
ImportError: No module named setuptools

所以....pip2.6 正在安装模块,仅适用于2.6.6.为了确保使用pip2.6下载的模块的默认目录是python 2.6.6,我缺少我要执行的步骤吗?还是pip2.6这里的方法错误?

So .... pip2.6 is installing modules, just not for 2.6.6. Is there a step I am missing, in order to ensure that python 2.6.6 is the default home for modules downloaded with pip2.6? Or is pip2.6 the wrong approach here?

根据要求:

MacBook-Pro-de-Pyderman:project Pyderman$ which -a python2.6
/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6
/usr/bin/python2.6
/usr/local/bin/python2.6

MacBook-Pro-de-Pyderman:project Pyderman$ which -a pip2.6
/usr/local/bin/pip2.6

注意:我最终将转向使用pyenv和/或virtualenv,但是目前,我希望在没有它们的情况下实现这一目标.

Note: I will eventually move to using pyenv and/or virtualenv, but for now, I'm looking to achieve this without them.

推荐答案

这应该适合您,请打开一个新的终端来执行以下命令:

This should work for you, please open a new terminal for executing these commands:

cd /tmp
wget https://bootstrap.pypa.io/get-pip.py
sudo /Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 get-pip.py

之后,pip2.6python2.6都应指向2.6.6解释器.

After that both pip2.6 and python2.6 should point to your 2.6.6 interpreter.

命令which python2.6应该打印

/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6

命令which pip2.6应该打印

/Library/Frameworks/Python.framework/Versions/2.6/bin/pip2.6

这篇关于OS X上的pip:已安装2.6 Python无法识别与pip2.6一起安装的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 23:28