Computing.Net > Forums > Programming > opening an image in python

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

opening an image in python

Reply to Message Icon

Name: greenbear
Date: December 2, 2006 at 13:42:44 Pacific
OS: xp
CPU/Ram: p4
Product: m
Comment:

Hey all,

I'm trying to do something very simple - open an image in python:

>>> img = Image.open("C:\Documents and Settings\Dmitry\Desktop\test.bmp")

but I get this error:

Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
img = Image.open("C:\Documents and Settings\Dmitry\Desktop\test.bmp")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1717, in open
fp = __builtin__.open(fp, "rb")
IOError: [Errno 2] No such file or directory: 'C:\\Documents and Settings\\Dmitry\\Desktop\test.bmp'

The error message has two backslashes instead of one for the bitmap location, which is rather preplexing. Any help is appreciated.



Sponsored Link
Ads by Google

Response Number 1
Name: Fozzie
Date: December 2, 2006 at 21:58:24 Pacific
Reply:

I'm not familiar with python, but in C++ there are certain characters that have a single slash in front of them. For example: \n means new line.

Because of this, if you want an actual forward slash, like in a path, then you have to use the forward slash character which is \\.

You might need to re-write your statement with double slashes instead of single.



0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: opening an image in python

Display an image in DOS www.computing.net/answers/programming/display-an-image-in-dos/12671.html

To open an exsting Oracle report in VB www.computing.net/answers/programming/to-open-an-exsting-oracle-report-in-vb/1524.html

Greek in Python www.computing.net/answers/programming/greek-in-python/10108.html