Why can't I import pygtk?

I followed the instructions in this post. Everything is installed successfully. However, when I run python, I cannot import pygtk. In particular, he says the following:

>>> import pygtk \n "ImportError: No module named pygtk"

I assume that I need to do some commands like make or something else, but I can not find anywhere where it says what to do. Please help, I'm very upset.

Edit: I should probably mention that I'm on Mac OS X

+3
source share
6 answers

How do you use python? Is this the one that comes with OSX (/ usr / bin / python) or the MacPorts version (/ opt / local / bin / python)?

, , pygtk MacPorts. python. . MacPorts wiki , PATH python.

: macports : "/opt/local/bin/python", pygtk. , macports python , , ( - /opt/local/lib/python2.5/site-packages).

+3

git mergetool , python pygtk. python virtualenv virtualenv.

+1

- , HomeBrew

meld - .

brew install python
+1

, ( macports). , , macports python. , X :

[user]$ /usr/bin/python
>>> import pip
>>> for package in pip.get_installed_distributions():
>>>     print package, package.location

/opt/local/bin/python ( python ) "import pip", , pip.

:

1) pip macports ( ). pygtk

2) python /usr/bin/python .

/opt python ( macports) , -macports, .

+1
a> pip install pygtk - (windows only), 
b> brew install python

, , , . .

0

, , , python , , , , : ( , , , ... , - )

1: python , (: , ). , , , ).... , , , )

2: , ( / - )

3: python, $PYTHONPATH, - script :

import sys
sys.path.append('\\path\\to_the_directory\\containing_themodule')

( , , , ) pytk \path\to_the_directory\contains_themodule\pytk '.

0
source

Source: https://habr.com/ru/post/1754929/


All Articles