Search code examples
pythonmoduleinstallationpipappkit

Python module error - beginner


So I'm trying to import AppKit into my python project. I am using pyCharm, but every time I try to import, I get the following error message:

You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting AppKit
Using cached AppKit-0.2.8.tar.gz
Collecting flask (from AppKit)
Using cached Flask-0.10.1.tar.gz
Collecting pygobject (from AppKit)
Using cached pygobject-2.28.3.tar.bz2
Traceback (most recent call last):
  File "<string>", line 20, in <module
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

  File "<string>", line 20, in <module

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3p/csss5m7x30ldjd4z0xt6sg380000gn/T/pycharm-packaging0.tmp/pygobject

I've tried running the command directly through terminal etc, and I have upgraded my version of pip to 6.1.1 as well.

Not sure if this is a really beginner's mistake that I am making, or if there is something wrong with my installs of pip or python.

Any advice would be great, thanks :D


Solution

  • First, "importing" and "installing" are not the same thing. Installing is how you get a PyPI package, and all of its dependencies, onto your computer, so you can use its modules. Importing is how you use a module that's already on your computer.

    Second, there are two different things named AppKit, and I think you've gotten them confused.

    If you're on a Mac, you're almost certainly trying to use import AppKit to get the PyObjC wrapper around the native Cocoa framework named AppKit. If you don't already have PyObjC installed (I believe it comes with Apple's built-in Python on OS X 10.8-10.10), you get it with pip install PyObjC, not pip install AppKit.

    If you're on Linux or FreeBSD or similar, you may be trying to import AppKit to get the AppKit framework for building GNOME GUI apps out of HTML and JavaScript. (Although this is in early stages, so I don't think you actually do want it.) For that, pip install AppKit is what you want. But you may need to install some system packages for GNOME development first with apt-get or urpmi or whatever's appropriate for your system.

    If you're on Windows or something else, neither one of these makes sense, so… hopefully you're not. :)