在OS X上安装和导入Python模块

在OS X上安装和导入Python模块

问题描述:

我已经尝试了几个小时.似乎IDLE找不到任何第三方模块.我是Python初学者.

I've been trying for a couple of hours already. It seems IDLE can't find any third-party module. I am a Python beginner.

以下是有关我的系统的一些信息:

Here is some info about my system:

  • OSX版本:10.11.5
  • python版本:Python 2.7,Python 3.4,Python 3.5

使用pip进行的初始安装(以及其他方法)似乎可以正常工作.当我重复安装时,终端会回应:

The initial installation using pip (among other methods) seems to work fine. When I repeat the installation, terminal responds with:

已满足要求(使用--upgrade进行升级):pyperclip in ./anaconda/lib/python3.4/site-packages

Requirement already satisfied (use --upgrade to upgrade): pyperclip in ./anaconda/lib/python3.4/site-packages

但是,当我进入IDLE(Python 3.4)并尝试导入模块时,IDLE响应:

However, when I go to IDLE (Python 3.4) and try to import the module, IDLE responds with:

回溯(最近一次通话最后一次):文件",第1行,在 import pyperclip ImportError:没有名为"pyperclip"的模块

Traceback (most recent call last): File "", line 1, in import pyperclip ImportError: No module named 'pyperclip'

我已阅读到它可能与我的PATH或某些虚拟环境有关.坦率地说,由于它们似乎超出了我目前的能力,因此我不确定该如何处理.

I have read that it may have something to do with my PATH or some virtual environment. I’ll be frank, I’m not sure what to make of these as they seem beyond my current ability.

无法导入模块正成为推进Python的几乎无法克服的障碍.如果您对我可以做什么或可以使用ELI5解决方案提出任何想法,那么我永远担负着您的责任?

This inability to import modules is becoming an almost insurmountable roadblock to advancing with Python. If you can offer any ideas on what I can do or can ELI5 the solution, I am forever in your debt?

似乎您正在使用conda,但您正在尝试使用pip安装pyperclip模块.您是否尝试过运行conda install pyperclip?

It seems you are using conda, but you are trying to install the pyperclip module with pip. Have you tried running conda install pyperclip?

此处所述:

由于Conda引入了新的包装格式,因此您不能将pip和Conda互换使用; pip无法安装Conda软件包格式.您可以并排使用这两个工具,但是它们都不可以互操作.

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side but they do not interoperate either.