cygwin: pillow cannot find libjpeg - python-imaging-library

Installing pillow 8.x/9.0 on cygwin currently fails.
It finds the jpeglib.h, but not the library (which exists, libjpeg-devel is installed):
$ ls -l /usr/include/jpeglib.h /usr/lib/libjpeg.dll.a
-rw-r--r-- 1 user group 50281 Nov 19 04:04 /usr/include/jpeglib.h
-rwxr-xr-x 1 user group 83496 Nov 23 01:10 /usr/lib/libjpeg.dll.a
setup.py output (with debugging enabled):
Looking for jpeg
Checking for include file jpeglib.h in /tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd
Checking for include file jpeglib.h in /usr/include
Found jpeglib.h
Couldn't find library jpeg in ['/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd', '/usr/lib', '/usr/local/lib', '/lib', '/usr/lib/python3.9/config', '/usr/lib']
[...]
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
Traceback (most recent call last):
File "/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd/setup.py", line 989, in <module>
setup(
File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 155, in setup
return distutils.core.setup(**attrs)
File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
_build_ext.run(self)
File "/usr/local/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-install-22fl1qzk/pillow_ff8a20e272ec40ee831aa9c1f2d606fd/setup.py", line 804, in build_extensions
raise RequiredDependencyException(f)
__main__.RequiredDependencyException: jpeg
How can I resolve this issue?

Not sure this is the best solution but I was having the same problem (Installing Pillow 9.1 on cygwin and using Python3.8) and it worked for me. The Pillow documentation (https://pillow.readthedocs.io/en/stable/installation.html) suggests editing setup.py if the libraries are not installed in standard locations. I think maybe the file location is correct in this instance but maybe the extension is unexpected. Regardless:
"If the prerequisites are installed in the standard library locations for your machine (e.g. /usr or /usr/local), no additional configuration should be required. If they are installed in a non-standard location, you may need to configure setuptools to use those locations by editing setup.py or setup.cfg, or by adding environment variables on the command line:"
So I edited setup.py to return the correct path for libjpeg.dll.a where searching for the jpeg library (more specifically i edited the _find_library_file function to return the exact path when searching for the libjpeg library). I then installed using pip and the setup ran successfully.

Pillow is already available on Cygwin, It is just named imaging
$ cygcheck -cd |grep imaging
python36-imaging 8.4.0-1
python36-imaging-tk 8.4.0-1
python37-imaging 8.4.0-1
python37-imaging-tk 8.4.0-1
python38-imaging 8.4.0-1
python38-imaging-tk 8.4.0-1
python39-imaging 8.4.0-1
python39-imaging-tk 8.4.0-1

Related

How can I import libraries in PythonAnywhere and use them in a Python notebook?

I'm both updating and installing packages/libaries, but are only able to use them through the Python3.6 console.
10:40 ~ $ pip3.6 install -U --user scikit-learn
Requirement already up-to-date: scikit-learn in ./.local/lib/python3.6/site-packages
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: joblib>=0.11 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: scipy>=0.17.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
When using pip install it fails with :
10:40 ~ $ pip install -U --user scikit-learn
Collecting scikit-learn
Using cached https://files.pythonhosted.org/packages/18/28/5a48b00599b476875415b97bdfdb3849bafb31183c1d785501dbc8a77aa2/scikit-learn-0.22.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-JYw8w1/scikit-learn/setup.py", line 47, in <module>
import sklearn
File "sklearn/__init__.py", line 81, in <module>
from . import __check_build # noqa: F401
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py _check_build.pyx __init__.pyc
setup.py
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
It appears that you are importing a local scikit-learn source tree. For
this, you need to have an inplace install. Maybe you are in the source
directory and you need to try from another location.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JYw8w1/scikit-learn/
If you've installed a package using pip3.6, make sure that your kernel version for your notebook is 3.6 -- if it's (say) 3.7, then it won't work, because each version of Python has its own separate set of installed modules.
I imported the notebook, and forgot to change Kernel Python3.6. It was still on Python3. Changed notebook to 3.6, and the it used the updated libary's-
When you run pip on PythonAnywhere, outside virtual environment, it installs packages for python2. The latest version of scikit-learn to work with python2 is 0.20.4. So, install it with pip install scikit-learn==0.20.4
You tried to install 0.22.1 with python2.

Virtualenv causing setuptools error

I am having trouble running a virtualenv, and I keep getting this same error code: "setuptools pip wheel failed with error code 1"
I saw some pages talking about how this is a discrepancy between different versions of setuptools, but I've uninstalled and reinstalled virtualenv and setuptools in several versions to no results. Does anyone know what's happening here?
Roberts-MacBook-Air:script Rob$ virtualenv venv
New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/__init__.py", line 13, in <module>
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl/pip/utils/__init__.py", line 15, in <module>
File "/Users/Rob/anaconda/lib/python2.7/zipfile.py", line 6, in <module>
import io
File "/Users/Rob/anaconda/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/Rob/Seedstages/script/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/Rob/anaconda/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/Rob/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/Rob/Seedstages/script/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1
Roberts-MacBook-Air:script Rob$
I would say that Anaconda causes the conflict, though to be more specific, it appears as if Anaconda's virtualenv is the problem. Running which virtualenv on my macbook (where I'm having the same problem) yields /Users/me/anaconda/bin/virtualenv while running it on the linux system I just tested this on yields /usr/local/bin/virtualenv.
So, on OS X, I downloaded virtualenv using /usr/local/bin/pip install virtualenv. This doesn't create a virtualenv binary (or it didn't for me) in the PATH folders, so I had to type this painfully long command:
sudo /usr/local/bin/python ... {the path to virtualenv.py in the system python's site-packages folder} new_env
And that did it. But that's ridiculous. No one wants to do that - even creating links would still be hacking it when you don't need to.
According to the ContinuumIO github page on this very subject, the virtualenv env and source /bin/activate commands are replaced with conda create -n env python=2.7 and source activate env.
Tested on my macbook (running Anaconda2 v4 on OS Yosemite) and it worked out.

mkvirtualenv: Too many levels of symbolic links

I am running virtualenv burrito and getting an error that there are too many levels of symbolic links. I have no idea what that means.
mkvirtualenv --python /usr/local/bin/Python3 mantis
Error:
Running virtualenv with interpreter /usr/local/bin/Python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in mantis/bin/Python3
Also creating executable in mantis/bin/python
Traceback (most recent call last):
File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 2352, in <module>
main()
File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 825, in main
symlink=options.symlink)
File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 985, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1439, in install_python
raise e
File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1431, in install_python
stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 859, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 1457, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 62] Too many levels of symbolic links
I was getting this error before and solved it by doing Python3.4 instead of Python3. Now it won't work no matter which python I try to use. Even if I try to use the default (2.7)
Strangely, I ran into this when I tried to create a virtualenv with a name that already existed. Solution to remove the old and create a new one:
rmvirtualenv old-one
mkvirtualenv new-one
I had the same problem on OSX.
I got rid of it after:
1. removing env folder
2. removing __pycache__ folder
The reason this wasn't working was because I was capitalizing Python. As soon as I did it using python3 instead of Python3 I stopped getting trouble.
I'm using a mac and I solved this by rm the virtual env that is named the same as you are trying to create. Specifically, I rm the folder within Users/user_name/.virtualenvs/. Then the create worked.
I'm not sure why but using
python3 -m venv venv
instead of
virtualenv -p python3 venv
and then activating the venv or setting the paths manually, something like this
export PYTHONPATH=.:\$PYTHONPATH
VIRTUAL_ENV=`pwd`/venv
export VIRTUAL_ENV
PATH="\$VIRTUAL_ENV/bin:\$PATH"
export PATH
worked for me.
I tried to do some quick searching of the different between virtualenv and python3 -m venv module...but didn't find anything.
I came across it after I had built my freshest environment. Because it has been interrupted by myself while it was building the new one. Then I noticed that virtualenvwrapper already created a new environment folder underneath the environment directory but it has not been accomplished properly. Hence, I deleted the lastest environment folder and retried to install same environment. It fixed!
I had the same problem in raspberry pi during open cv installation.
I solve my problem by using below method.
Go to /home/pi
ls -all and check weather .virtualenvs is there or not
if it is there remove it by
rm -r .virtualenvs
File "/Users/croberts/? seems you're using Windows. Consider using 'virtualenvwrapper-win'. The latest version is 1.2.0 which support python 2 up to 3.4. I've used it without any problems. If you use several versions of python on your computer, you can switch between them using 'pywin'.
For making new virtualenv:
C:\Users\your_directory>mkvirtualenv neo
Using base prefix 'C:\\Python34'
New python executable in neo\Scripts\python.exe
Installing setuptools, pip...done.
For view existing virtualenv:
C:\Users\your_directory>lsvirtualenv
dir /b /ad "C:\Users\your_directory"
=========================================================================
env0
env1
env2
neo

Distutils.core could not be found, where can I download it

Traceback (most recent call last):
File "setup.py", line 26, in <module>
from distutils.core import setup, Extension, Command
ImportError: No module named distutils.core
I get this error when installing ctypes.py on openwrt. Unfortunately, I cannot find the download link to the setup for distutils.core.
Can someone point me to it?
distutils ships in Python’s standard libary. Some operating systems think it’s not a regular module but only interesting for developers, so they move it to a python-devel package together with C headers, config files and co. https://dev.openwrt.org/ticket/793 tells me that this is the case for OpenWRT: you need to install python-dev to get distutils installed.
While logged in to openwrt try:
opkg update
opkg install distribute

Installing XML::Parser requires expat.h

I'm working on a project that requires all third-party (read: CPAN) perl modules to be installed in a perforce repository, so that any code that depends on them can be successfully run without anyone else needing to manually install them. I ran into an issue though when trying to install XML::Parser. I use cpanminus to install my CPAN modules, so I ran cpanm -L . XML::Parser in the desired directory (this has worked before with other modules) and got the error:
Expat.xs:12:19: error: expat.h: No such file or directory
I'm used to using Ubuntu and apt-get, but at work I have to use RedHat and I'm not sure how to install expat to a local directory. I ran yum search expat and got
expat.i386 : A library for parsing XML.
expat.x86_64 : A library for parsing XML.
So I tried yum install --installroot=. expat.i386 and got the following errors:
Loaded plugins: rhnplugin, security
error: cannot open Packages index using db3 - No such file or directory (2)
error: cannot open Packages database in ./var/lib/rpm
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 309, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 157, in main
base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 187, in getOptionsConfig
self.conf
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 665, in <lambda>
conf = property(fget=lambda self: self._getConfig(),
File "/usr/lib/python2.4/site-packages/yum/__init__.py", line 240, in _getConfig
self._conf = config.readMainConfig(startupconf)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 804, in readMainConfig
yumvars['releasever'] = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.4/site-packages/yum/config.py", line 877, in _getsysver
idx = ts.dbMatch('provides', distroverpkg)
TypeError: rpmdb open failed
What am I doing wrong? Also, once I do get expat installed, I'm not sure how I would tell cpanm where to find it.
I see a couple of things that could help get you on the right path. First, the package you want is called expat-devel. Also, I think you need to provide an absolute path to the --installroot option, and you probably don't need to provide the package extension to yum unless this is relevant to how you building these modules (i.e., you can usually just do yum install expat-devel).
It also looks like something may be wrong with your rpmdb, since you got the "rpmdb open failed" message. You can run yum check to look for problems in rpmdb, but beyond that I can't say anything specifically going on with the package manager. Perhaps others can help more with that aspect.
just install expat by downloading it from http://sourceforge.net/projects/expat/ and
$ ./config
$ make
$ make install
Well, I found a workaround. I installed XML::Simple instead. At first it looked like XML::Simple required XML::Parser, but after some looking found out that it requires either XML::Parser OR XML::SAX, so I installed XML::SAX instead and got XML::Simple working. Good enough for my needs.