-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (unknown location) #4130
Comments
How did you install Pillow? Googling, I would conclude that there is something strange about your installation, rather than anything specific to Pillow. I would be curious about what is printed by this code, and whether it makes a difference - import sys
print(sys.path)
sys.path.append('/lib/python3.7/site-packages')
from PIL import Image |
@radarhere i did it by usual way pip3 install Pillow. After this: import sys
print(sys.path)
sys.path.append('/lib/python3.7/site-packages')
from PIL import Image I got another an import error but different: Should I reinstall it by some specific way? |
Installing it through pip should be fine. What operating system are you using? Have you tried uninstalling it and re-installing it to see if that fixes anything? |
@radarhere , yeah, of course I did... Thanx for you help, now I see it's maybe some environment problem. |
Another thought - considering that the first problem means that Python wasn't able to import the package correctly in some way, you might try |
@poormag if you resolve this, be sure to let us know, so we can close the issue, and maybe leave a note of the solution for the sake of anyone arriving here in the future. Thanks for using Pillow. Unfortunately it is harder to remotely debug install problems. |
For For another idea, Python 3.8 has also been released. While not a solution to your problem, you may be interested in upgrading, and that new environment may work for you. |
I'm getting the same error right now after Looks like downgrading to pillow 6.1 helps.. after |
@stmax82 Please report Conda issues to https://github.com/conda-forge/pillow-feedstock. It sounds a bit like conda-forge/pillow-feedstock#66 ("DLL import fails in fresh conda install"), fixed yesterday. I'll close this issue, @poormag let us know if this is still a problem with pip and we can re-open. |
I met the same problem. I am using python3.7.5 on macos. When using |
@WeiQijie In 7.0.0:
https://pillow.readthedocs.io/en/stable/releasenotes/7.0.0.html#pillow-version-constant |
This one worked for me, thanks for sharing, I really struggled with this the whole Day. Thanks again! |
I recommend updating your code to use
If you still need to work with try:
from PIL import __version__
except ImportError:
from PIL import PILLOW_VERSION as __version__ |
I had the same error when using docker to build a Linux based image in Windows 10 with fastai. Added "RUN pip install Pillow==6.1" above "RUN pip install fastai" in the Dockerfile and following the build, the container successfully ran. Thanks for your posts. |
had the same error while using pytorch code which had deprecated pillow code. since PILLOW_VERSION was deprecated, i worked around it by: Simply duplicating the _version file and renaming it as PILLOW_VERSION.py in the same folder. worked for me |
perhaps one of the most stupid things ever done. Boycotting 7.0.0 version Rolling back to 6.2.2 |
torchvision v0.5.0 has been released with the fix:
|
@hugovk can someone release the Windows version of torchvision 0.5.0 to pipy and conda? Last version with a Windows wheel is https://pypi.org/project/torchvision/0.4.1/#files |
@asears Please ask at the torchvision project. This might be the right place: pytorch/vision#1717 (Edit: fixed link, but pytorch/vision#1756 seems relevant and I see you already commented there 👍) |
IDK
чт, 2 апр. 2020 г. в 11:33, Antupis <notifications@github.com>:
… I just set pillow version when I imported code
`
import PIL
PIL.PILLOW_VERSION='7.0.0'
import PIL.Image as Image
`
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALH6ZJDDNPZS6N24MBH5PB3RKREWPANCNFSM4I7XCONQ>
.
|
Try this method:
Simple method! if the Error is (Given below), the above method will work.
The method is tested on windows and ubuntu |
@shanethomas1029 hi, sorry, not quite following. What triggered the error |
I's already done:
PILLOW_VERSION='7.0.0'
And it's working ...
вс, 5 апр. 2020 г. в 14:17, shanethomas1029 <notifications@github.com>:
Try this method:
First, uninstall the Pillow package from your system
1. python -m pip uninstall Pillow
Second, Reinstall it!
2. python -m pip install Pillow
Simple method!
if the Error is (Given below), the above method will work.
Traceback (most recent call last):
File "main.py", line 3, in
from PIL import Image
File
"C:\Users\shane\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py",
line 44, in
from . import (
ImportError: cannot import name '*raise_version_warning' from 'PIL'
(C:\Users\shane\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL_init*
.py)
The method is tested on windows and ubuntu
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALH6ZJGEDHWKZ2GMGYGJIB3RLBSERANCNFSM4I7XCONQ>
.
from torchvision import models
from torchvision import datasets
from torchvision import ops
from torchvision import transforms
from torchvision import utils
from torchvision import io
try:
from .version import __version__ # noqa: F401
except ImportError:
pass
_image_backend = 'PIL'
PILLOW_VERSION='7.0.0'
def set_image_backend(backend):
"""
Specifies the package used to load images.
Args:
backend (string): Name of the image backend. one of {'PIL', 'accimage'}.
The :mod:`accimage` package uses the Intel IPP library. It is
generally faster than PIL, but does not support as many operations.
"""
global _image_backend
if backend not in ['PIL', 'accimage']:
raise ValueError("Invalid backend '{}'. Options are 'PIL' and 'accimage'"
.format(backend))
_image_backend = backend
def get_image_backend():
"""
Gets the name of the package used to load images
"""
return _image_backend
|
You got it? |
Okay |
OK
пн, 6 апр. 2020 г. в 12:37, shanethomas1029 <notifications@github.com>:
… @shanethomas1029 <https://github.com/shanethomas1029> hi, sorry, not
quite following. What triggered the error cannot import name
'raise_version_warning' from 'PIL'?
You got it?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALH6ZJGTEXBWAQLAVYKTROLRLGPEPANCNFSM4I7XCONQ>
.
|
Such an unnecessary changes. It almost feel like people here are bored and trying to find ways to broke old codes. Thanks for fix btw @zealousfool |
|
I can verify that:
Reinstalling/installing Pillow 7.1.0 fixes the problem. |
Hello.
OK.
Thank you!
It's working now too.
I DID it!
It's more prefer to use some installations than to write the code ...
Good-bye!
пт, 10 апр. 2020 г. в 18:30, Greg Tarr <notifications@github.com>:
… PILLOW_VERSION was re-added in Pillow 7.1.0, released 2020-04-01, to give
projects more time to upgrade:
-
https://pillow.readthedocs.io/en/stable/releasenotes/7.1.0.html#pillow-version-constant
-
https://pillow.readthedocs.io/en/stable/deprecations.html#pillow-version-constant
- #4494 <#4494>
I can verify that:
python -m pip uninstall Pillow
python -m pip install Pillow
Reinstalling/installing Pillow 7.1.0 fixes the problem.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4130 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALH6ZJE7W6H5UQL4BC7QDNTRL43RXANCNFSM4I7XCONQ>
.
|
Add the following line to your_path\Anaconda\Lib\site-packages\PIL_init_.py:
|
This works for me as well! |
* Syncing staging <> master branches (#476) * Removed submodules. * Add back submodules using https:// * simplified plotting functions * fixed most tests * fixed test * fixed unit test * small text edits to the 02 notebook * added fct description * tiny cleanup on notebook * Add pretrained keypoint model (#453) * Add pretrained keypoint model * Fix bugs in tests * Add 03 notebook in conftest.py * Minor revision * Reformat code using black * if folder exists, remove (#448) * Add mask annotation tool (#447) * Add mask annotation tool * Update mask annotation explanation and add converion scripts * Add screenshots of Labelbox annotation * Rearrange screenshots * Move convertion script into functions in data.py * Point out annotation conversion scripts clearly in notebook * Refine annotation conversion scripts * Fix bugs * Add tests for labelbox format conversion methods * Move r2p1d from contrib to scenarios. * Update .gitignore. * Add README.md * Remove the folder /scenario/action_recognition/data/samples; update notebook to use web url for sample data. * Move data split files to data/misc; update notebook accordingly. * Update data path. * Add keypoint detection with tuned model (#454) * Add keypoint detetion with tuned model * Add tests * Minor revision * Update tests * Fix bugs in tests * Use GPU device if available * Update tests * Fix bug: 'not idx' will be 'True' if 'idx=0' * Fix bugs * Move toy keypoint meta into notebook * Fix bugs * Fix bugs * Fix bugs in notebook * Add descriptions for keypoint meta data * Raise exception when RandomHorizontalFlip is used without specifying hflip_inds * Add NOTICE file. * Add keypoint detection model tuning with top and bottom keypoints (#456) * Add keypoint detection model tuning with top and bottom keypoints * Fix undefined unzip_url * Resolved undefined od_urls * Add annotation tool to scenarios. * Plot keypoints as round dots to make them noticeable (#458) * Plot keypoints as dots * Change variable naming * Resolve test machine failure (#460) This is due to the latest PyTorch (version 1.3) from conda is built on CUDA 10.1 while the version on the test machine is CUDA 10.0. * Remove unused imports in 02_mask_rcnn.ipynb (#463) * Remove unused imports in 02_mask_rcnn.ipynb * Add missing imports * Simplify binary_mask() (#464) * clean up of keypoint detection notebook * minor clean-up * remove conflict code (#471) * Update README.md (#472) * updated readmes * added images * updated readmes * added intro figure * modified new picture * update figure * Move to bare Windows GPU VMs and fix build issues (#475) * Updating AzureDevOps pipeline agent pool to use a barebones Windows GPU VM. * Added a AzureDevOps pipeline for windows. * Added a conda init step for powershell. * Adding conda to PATH as a separate step * Pinning pillow to 6.1 to fix issues listed in: python-pillow/Pillow#4130 * chained powershell commands * Updated AzureDevOps yml file to use the inline powershell script syntax. * Moved to using inline commands + Invoke-Expression syntax * Adding indentation for chained commands. * Moving to the literal block style indicator for yaml for chained commands. * Using call activate instead of source activate when activating the conda environment through powershell. * Switching to script steps instead of using powershell steps for conda operations. * Fixed the numpy.float64 issue by moving to a fork with the upstream fixes for the issue. * Fixed the numpy.float64 issue in utils/cv/detection/plot.py Co-authored-by: PatrickBue <pabuehle@microsoft.com> Co-authored-by: Simon Zhao <43029286+simonzhaoms@users.noreply.github.com> Co-authored-by: Miguel González-Fierro <3491412+miguelgfierro@users.noreply.github.com> Co-authored-by: JS <jiata@microsoft.com> * fix to load from saved mask-rcnn model * fix to load from saved mask-rcnn model * fix to load from saved mask-rcnn model Co-authored-by: Young Park <youngpark@cs.stanford.edu> Co-authored-by: PatrickBue <pabuehle@microsoft.com> Co-authored-by: Simon Zhao <43029286+simonzhaoms@users.noreply.github.com> Co-authored-by: Miguel González-Fierro <3491412+miguelgfierro@users.noreply.github.com> Co-authored-by: JS <jiata@microsoft.com>
Hello, I have a similar problem, could you please help me check the error:
|
@DAVID-Hown I recommend that you upgrade Pillow to at least 7.1.0, or torchvision to at least 0.5.0. |
As has been previously stated, PILLOW_VERSION was brought back in Pillow 7.1.0. In case it is a concern to anyone in this thread, Pillow 9.0.0, due out on January 1, will remove PILLOW_VERSION again. |
|
The following code fixed the problem (python 3.7, linux): |
This is what I did and worked out perfectly
|
Try this in the script that tries to
not guaranteed to work with all cases though, you need to dig up a bit This is so much headache |
This comment was marked as off-topic.
This comment was marked as off-topic.
This is definitely what I am looking for, especially in cases pillow or python version can not be downgraded! |
Hi. If anyone has a problem with this, please open a new issue to discuss it. We would like people to use the latest version of Pillow possible, so downgrading is not an ideal solution. If the problem is another library still using |
I got this error while importing Image
I tried to remove it by myself but then got the same problem with
__version__
, then_plugins
Updating doesn't work for me. Can you help please?
The text was updated successfully, but these errors were encountered: