[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What's needed for jpegtran in Python 3?

On Thursday, September 27, 2018 at 10:48:16 AM UTC-7, Chris Green wrote:
> I think that must be what I have already installed, it doesn't make
> the module available in Python 3, it just says this when I try and
> install it:-
>     root at t470:~# pip install jpegtran-cffi
>     Requirement already satisfied: jpegtran-cffi in /usr/local/lib/python2.7/dist-packages
>     Requirement already satisfied: cffi>=0.8 in /usr/lib/python2.7/dist-packages (from jpegtran-cffi)
>     root at t470:~# 
> Python 3 isn't going to find that is it?  When I run my program it
> says:-
>     chris$ picimport.py
>     Traceback (most recent call last):
>       File "/home/chris/bin/picimport.py", line 28, in <module>
>         from jpegtran import JPEGImage
>     ModuleNotFoundError: No module named 'jpegtran'
>     chris$ 

It appears that you are working in Linux.  Many of the command-line Linux utilities are written in Python 2.7.  In a few years that may change, for now Py 2.7 is the system Python.

On a Linux system, when you type "python" you will start the system's Py 2.7 interpreter.  When you type "pip" you will start the installer for Py 2.7.  So you installed jpegtran, but you installed it for Py 2.7.

Linux (Ubuntu, at least, I'm not sure about other distros) also ships with a version of Python 3, but it's not the default.  If you want to invoke Py 3.x from a Linux command prompt, you need to type "python3".  If you want to install packages for your Python 3 platform, you need to install python3-pip, a system package which is not included in (Ubuntu) Linux by default.  You can access that package from the command line by typing "pip3" where you would have typed "pip".

It's good that you want to use Py 3, in a few years the changeover will be complete.  The one thing you did not show was your text for picimport.py, which I expect is trying to use Py 3.