It is currently Sat Apr 20, 2024 4:31 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Installing a new python package in gimp
PostPosted: Sat Jul 04, 2015 8:40 pm  (#1) 
Offline
GimpChat Member

Joined: Jun 08, 2015
Posts: 6
I`m trying to use the python package natsort in gimp, and I`m unsure how to get it to work. I`ve downloaded the package, and moved the .py files into the plugin directory, but when I try to run "import natsort" in the gimp console, I get the error "ImportError: no module named ns_enum" even though the file ns_enum.py is in the plugin directory (in fact, I can run "import ns_enum" without any problems). I'm thinking I didn't install the package properly, so my question is, how do you install a new python package for use in gimp?

I'm using GIMP version 2.8.14 on Windows 7.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Installing a new python package in gimp
PostPosted: Sun Jul 05, 2015 4:21 am  (#2) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Only Gimp plug-ins go into the Gimp plug-ins folder.
natsort.py is a standard Python library module and must be properly installed in the Python directory tree so that the Python interpreter can find the pre-compiled .pyc files (ns_enum.pyc, etc).

On Linux, I just did this on a terminal window:
$ pip install natsort

and I could then immediately import the module into Gimp's Python Console:
>>> import natsort
>>> a = ['a2', 'a9', 'a1', 'a4', 'a10']
>>> sorted(a)
['a1', 'a10', 'a2', 'a4', 'a9']
>>>

I'm not sure what the installation process for Python modules is on Windoze - refer to the Python docs at https://www.python.org/


Top
 Post subject: Re: Installing a new python package in gimp
PostPosted: Mon Jul 06, 2015 11:57 am  (#3) 
Offline
GimpChat Member

Joined: Jun 08, 2015
Posts: 6
jontait2 wrote:
Only Gimp plug-ins go into the Gimp plug-ins folder.
natsort.py is a standard Python library module and must be properly installed in the Python directory tree so that the Python interpreter can find the pre-compiled .pyc files (ns_enum.pyc, etc).

On Linux, I just did this on a terminal window:
$ pip install natsort

and I could then immediately import the module into Gimp's Python Console:
>>> import natsort
>>> a = ['a2', 'a9', 'a1', 'a4', 'a10']
>>> sorted(a)
['a1', 'a10', 'a2', 'a4', 'a9']
>>>

I'm not sure what the installation process for Python modules is on Windoze - refer to the Python docs at


I tried installing the package like normal in Python on Windows 7 (running "python setup.py install" in the command prompt), but while the package is properly installed in python (I get it to work in Python's IDLE), the module still can't be imported when I go to the Gimp Python Console.


Top
 Post subject: Re: Installing a new python package in gimp
PostPosted: Mon Jul 06, 2015 12:38 pm  (#4) 
Offline
Script Coder
User avatar

Joined: Dec 27, 2014
Posts: 508
Yeah, the Windows port of Gimp uses a "private" copy of the Python 2.x interpreter, which is stored in the the Gimp directory tree:
C:\Program Files\GIMP 2\Python
and all modules must be installed in the \Lib sub-folder of that \Python folder.

I haven't actually tried this on Windoze, but, once you've used the standard installer to download a module package into the standard Python installation, you should be able to just copy the entire folder (which contains all the .py, .pyc and any .pyo files) into Gimp's Python\Lib folder.

[Tip: if in doubt, just use your file manager to search for "antigravity.py" (a Python in-joke) - you should see one copy in each standard version of Python you have installed and one in the Gimp's directory tree. So copy the module you want from wherever you see it in the standard Python tree to wherever antigravity.py is in the Gimp directory tree and it should then work.]


Top
 Post subject: Re: Installing a new python package in gimp
PostPosted: Mon Jul 06, 2015 3:10 pm  (#5) 
Offline
GimpChat Member

Joined: Jun 08, 2015
Posts: 6
jontait2 wrote:
Yeah, the Windows port of Gimp uses a "private" copy of the Python 2.x interpreter, which is stored in the the Gimp directory tree:
C:\Program Files\GIMP 2\Python
and all modules must be installed in the \Lib sub-folder of that \Python folder.

I haven't actually tried this on Windoze, but, once you've used the standard installer to download a module package into the standard Python installation, you should be able to just copy the entire folder (which contains all the .py, .pyc and any .pyo files) into Gimp's Python\Lib folder.

[Tip: if in doubt, just use your file manager to search for "antigravity.py" (a Python in-joke) - you should see one copy in each standard version of Python you have installed and one in the Gimp's directory tree. So copy the module you want from wherever you see it in the standard Python tree to wherever antigravity.py is in the Gimp directory tree and it should then work.]


Thank you, I got it working now.


Top
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts SAMJ's package for 2.10.20

2

No new posts Attachment(s) JVID A thru I package with amended versions

3

No new posts Attachment(s) SAMJ package update for Gmic

5

No new posts Convert GIMP plugin from Python 2 to Python 3

3

No new posts Attachment(s) GMIC not installing

2



* Login  



Powered by phpBB3 © phpBB Group