Installing PIL for anaconda python2.7 - python

I can't figure out how to install PIL on my Mac (Sierra 10.12.4) running Anaconda (conda 4.3.18) python 2.7.10. Anaconda's default python is 3.5.2, so I'm installing with pip2.
My-MacBook-ProX:dymax thisuser$ sudo pip2 install PIL
Password:
Checking the installation location...
Getting information about 'PIL'...
2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
Traceback (most recent call last):
File "/Users/thisuser/anaconda3/bin/pip2", line 11, in <module>
load_entry_point('pip2==0.0.1.dev1', 'console_scripts', 'pip2')()
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/__init__.py", line 19, in main
args.func(args)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/cli_wrapper.py", line 24, in install
result = pip2.commands.install.install(args.project_list)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/pip2/commands/install.py", line 44, in install
success = packaging.install.install(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 515, in install
info = get_infos(project)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/install.py", line 309, in get_infos
installed = list(get_distributions(use_egg_info=True))
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 440, in get_distributions
_generate_cache(use_egg_info, paths)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 103, in _generate_cache
for dist in _yield_distributions(gen_dist, gen_egg, paths):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 88, in _yield_distributions
yield Distribution(dist_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/database.py", line 146, in __init__
self.metadata = Metadata(path=metadata_path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 219, in __init__
self.read(path)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 323, in read
self.read_file(fp)
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 330, in read_file
for field in _version2fieldlist(self['Metadata-Version']):
File "/Users/thisuser/anaconda3/lib/python3.5/site-packages/distutils2/metadata.py", line 95, in _version2fieldlist
raise MetadataUnrecognizedVersionError(version)
distutils2.errors.MetadataUnrecognizedVersionError: 2.0
I get identical error for sudo pip2 install pillow. I also tried with conda:
My-MacBook-ProX:dymax thisuser$ conda install pillow
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /Users/thisuser/anaconda3:
#
pillow 4.1.1 py35_0
In Python3 I can import PIL. Python2.7 I still get No module named PIL. Grateful for assistance. Is my pip/pip2 configured incorrectly?

Try by giving version
pip install pillow==6.1.0(latest)
If Doesn't work try
pip list
If not listed search location of python
which python
Search for site-packages folder inside resultant location of 'python' (usually under lib/python3.5/site-packages) and check if PIL present or not(packages are not installing right location)

Related

flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "D" due to invalid syntax upon install

I installed flake8 and flake8 docstrings globally using this:
sudo pip install flake8 flake8-docstrings
I tried to launch flake8 but i am faced with this error:
flake8 --version
Traceback (most recent call last):
File "/usr/local/bin/flake8", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/flake8/main/cli.py", line 18, in main
app.run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 393, in run
self._run(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 380, in _run
self.initialize(argv)
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 363, in initialize
self.find_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/main/application.py", line 199, in find_plugins
self.check_plugins.load_plugins()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 410, in load_plugins
plugins = list(self.manager.map(load_plugin))
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 297, in map
yield func(self.plugins[name], *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 408, in load_plugin
return plugin.load_plugin()
File "/usr/local/lib/python2.7/dist-packages/flake8/plugins/manager.py", line 165, in load_plugin
raise failed_to_load
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "D" due to invalid syntax (checker.py, line 668).
I fixed it by downgrading pydocstyle to 3.0.0.
pip install pydocstyle=3.0.0

Setup tool install pylint for py2.75

Due to firewall blocked the pip installer , I have to download the tar file and use setup tool to install package as below :
python setup.py install
My python version is py 2.75 so I choosed the pylint 1.9.3 according to instruction.
But it turns out below error message :
Couldn't find index page for 'pytest-runner' (maybe misspelled?) No
local packages or download links found for pytest-runner Traceback
(most recent call last): File "setup.py", line 181, in
install() File "setup.py", line 178, in install
**kwargs) File "C:\Program Files (x86)\Python27\lib\distutils\core.py", line 112, in setup
_setup_distribution = dist = klass(attrs) File "C:\Program Files (x86)\Python27\lib\site-packages\setuptools\dist.py", line 260, in
init
self.fetch_build_eggs(attrs.pop('setup_requires')) File "C:\Program Files
(x86)\Python27\lib\site-packages\setuptools\dist.py", line 284, in
fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg File "C:\Program Files
(x86)\Python27\lib\site-packages\pkg_resources__init__.py", line 777,
in resolve
replace_conflicting=replace_conflicting File "C:\Program Files (x86)\Python27\lib\site-packages\pkg_resources__init__.py", line
1060, in best_match
return self.obtain(req, installer) File "C:\Program Files (x86)\Python27\lib\site-packages\pkg_resources__init__.py", line
1072, in obtain
return installer(requirement) File "C:\Program Files (x86)\Python27\lib\site-packages\setuptools\dist.py", line 327, in
fetch_build_egg
return cmd.easy_install(req) File "C:\Program Files (x86)\Python27\lib\site-packages\setuptools\command\easy_install.py",
line 434, in easy_install
self.local_index File "C:\Program Files (x86)\Python27\lib\site-packages\setuptools\package_index.py", line
475, in fetch_distribution
return dist.clone(location=self.download(dist.location, tmpdir)) AttributeError: 'NoneType' object has no attribute 'clone'
I found it is setuptools issue.
I reinstall the setuptools but it does not work.
Search for "easy_install" in Scripts folder, find some old easy_installxxx pyc,py file/folder which is older than my reinstall date.
Delete them.
Reinstalled the setuptools
easy_install --version
It shows latest version now.
Then do again
python setup.py install
Now it works.

pip3 not installing packages

I enter the following line into terminal:
pip3 install numpy
this gives me:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 9, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/__init__.py", line 233, in main
return command.main(cmd_args)
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 251, in main
timeout=min(5, options.timeout)) as session:
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/basecommand.py", line 72, in _build_session
insecure_hosts=options.trusted_hosts,
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/download.py", line 93, in user_agent
from pip._vendor import distro
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 1050, in <module>
_distro = LinuxDistribution()
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 594, in __init__
if include_lsb else {}
File "/usr/local/lib/python3.5/dist-packages/pip-9.0.1-py3.5.egg/pip/_vendor/distro.py", line 931, in _get_lsb_release_info
raise subprocess.CalledProcessError(code, cmd, stdout, stderr)
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1
Im thinking its a path issue but im not really sure.
This is a bug with the distro package vendored by pip. The bug has been solved but the latest version of pip uses and very old version of distro which doesn't have this bug fix applied.
For now, you can simply try to make the executable available in the path.

Setuptools installation in Jython

Latest Jython standalone (2.7 final), latest setuptools:
C:\projects_intellij\test_jython>jython.bat ez_setup.py
C:\projects_intellij\test_jython>java -jar "C:\projects_intellij\test_jython\jython-standalone-2.7.0.jar" ez_setup.py
Extracting in C:\Users\myuser\AppData\Local\Temp\tmpt_1anc
Now working in C:\Users\myuser\AppData\Local\Temp\tmpt_1anc\setuptools-21.2.2
Installing Setuptools
Traceback (most recent call last):
File "ez_setup.py", line 425, in <module>
sys.exit(main())
File "ez_setup.py", line 422, in main
return _install(archive, _build_install_args(options))
File "ez_setup.py", line 59, in _install
if not _python_cmd('setup.py', 'install', *install_args):
File "ez_setup.py", line 51, in _python_cmd
return subprocess.call(args) == 0
File "C:\projects_intellij\test_jython\jython-standalone-2.7.0.jar\Lib\subprocess.py", line 500, in call
File "C:\projects_intellij\test_jython\jython-standalone-2.7.0.jar\Lib\subprocess.py", line 830, in __init__
File "C:\projects_intellij\test_jython\jython-standalone-2.7.0.jar\Lib\subprocess.py", line 1311, in _execute_child
TypeError: args must contain only strings
Is there a way to install this using Jython? Should I have used Jython installed by the installer instead of standalone?
Platform: Win 7 x64.
Yes, I think you should have.
It looks like a version problem.
Same here:
https://sourceforge.net/p/jython/mailman/jython-users/thread/CAOhO%3DaNmNL6xeKES2JXPkg%2BP3OTBxJCESNA0YtfLVX1L1fv85w#mail.gmail.com/

Unable to install any packages using easy_install [duplicate]

This question already has answers here:
Unable to install Flask-Mail
(2 answers)
Closed 6 years ago.
Whenever I run the command pip install Django I get the following error trace which means there is some version conflict. I tried uninstalling and then installing the same package, but it's throwing up the same error.
Downloading/unpacking bcrypt (from Django)
Downloading bcrypt-2.0.0.tar.gz
Running setup.py (path:/tmp/pip_build_root/bcrypt/setup.py) egg_info for package bcrypt
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/bcrypt/setup.py", line 226, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2016.2.28 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('certifi==2015.11.20'))
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/bcrypt/setup.py", line 226, in <module>
**keywords_with_side_effects(sys.argv)
File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 225, in __init__
_Distribution.__init__(self,attrs)
File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 257, in finalize_options
ep.require(installer=self.fetch_build_egg)
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 2029, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "/usr/local/lib/python2.7/dist-packages/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (certifi 2016.2.28 (/usr/local/lib/python2.7/dist-packages), Requirement.parse('certifi==2015.11.20'))
----------------------------------------
Cleaning up...
I am using Python 2.7. Anybody knows what is the issue?
It seems like all the problem is because of certifi version conflict
so try downloading the source from here
https://pypi.python.org/pypi/certifi
and install from source
Extract it go into the folder and run this command
sudo python setup.py install
and it should work
peace
I met such a situation when I had already used system package manager like aptitude or pacman to install that very package, or dependency package
(they, pip and system package manager, do not know each other, while they install package at the same folder, some site-package thing, so it's easy to get a file already exist like problem)
You need to see which is conflict, open your python console, try to import it, and see where is it with module_name.file, remove it(or the folder) manually (please backup before problem really solved).
Or just use pip and system package manager to verify which has been already installed

Categories