python 打开图片 没有权限,Imageopen()无法识别图像文件-Python?

曾晨
2023-12-01

我在VisualStudio2013中运行python2.7。该代码曾经在Spyder中正常工作, 但是当我运行时:

import numpy as np

import scipy as sp

import math as mt

import matplotlib.pyplot as plt

import Image

import random

# (0, 1) is N

SCALE = 2.2666 # the scale is chosen to be 1 m = 2.266666666 pixels

MIN_LENGTH = 150 # pixels

PROJECT_PATH = 'C:\\cimtrack_v1'

im = Image.open(PROJECT_PATH + '\\ST.jpg')

我收到以下错误:

Traceback (most recent call last):

File "", line 1, in

File "C:\cimtrack_v1\PythonApplication1\dr\trajgen.py", line 19, in

im = Image.open(PROJECT_PATH + '\\ST.jpg')

File "C:\Python27\lib\site-packages\PIL\Image.py", line 2020, in open

raise IOError("cannot identify image file")

IOError: cannot identify image file

为什么会这样以及如何解决呢?

如建议的那样, 我为我的Python2.7使用了Pillow安装程序。但是, 奇怪的是, 我得到了:

>>> from PIL import Image

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named PIL

>>> from pil import Image

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named pil

>>> import PIL.Image

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named PIL.Image

>>> import PIL

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named PIL

每个人都失败了!

 类似资料: