简体   繁体   English

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

[英]Installing and importing Python Modules onto OS X

I've been trying for a couple of hours already. 我已经尝试了几个小时。 It seems IDLE can't find any third-party module. 似乎IDLE找不到任何第三方模块。 I am a Python beginner. 我是Python初学者。

Here is some info about my system: 以下是有关我的系统的一些信息:

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

The initial installation using pip (among other methods) seems to work fine. 使用pip进行的初始安装(以及其他方法)似乎可以正常工作。 When I repeat the installation, terminal responds with: 当我重复安装时,终端会回应:

Requirement already satisfied (use --upgrade to upgrade): pyperclip in ./anaconda/lib/python3.4/site-packages 已经满足要求(使用--upgrade进行升级):./anaconda/lib/python3.4/site-packages中的pyperclip

However, when I go to IDLE (Python 3.4) and try to import the module, IDLE responds with: 但是,当我进入IDLE(Python 3.4)并尝试导入该模块时,IDLE响应为:

Traceback (most recent call last): File "", line 1, in import pyperclip ImportError: No module named 'pyperclip' 追溯(最近一次调用):文件pyperclip中的行1,导入错误ImportError:没有名为“ pyperclip”的模块

I have read that it may have something to do with my PATH or some virtual environment. 我已经读到它可能与PATH或某些虚拟环境有关。 I'll be frank, I'm not sure what to make of these as they seem beyond my current ability. 坦率地说,我不确定该怎么做,因为它们似乎超出了我目前的能力。

This inability to import modules is becoming an almost insurmountable roadblock to advancing with Python. 无法导入模块正成为推进Python的几乎无法克服的障碍。 If you can offer any ideas on what I can do or can ELI5 the solution, I am forever in your debt? 如果您对我可以做什么或可以使用ELI5解决方案提出任何想法,那么我永远担负着您的责任?

It seems you are using conda, but you are trying to install the pyperclip module with pip . 似乎您正在使用conda,但是您尝试使用pip安装pyperclip模块。 Have you tried running conda install pyperclip ? 您是否尝试过运行conda install pyperclip

As stated here : 如前所述这里

Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; 由于Conda引入了新的包装格式,因此您不能将pip和Conda互换使用; pip cannot install the Conda package format. pip无法安装Conda软件包格式。 You can use the two tools side by side but they do not interoperate either. 您可以并排使用这两个工具,但是它们都不可以互操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM