Print Error - Cannot open file: permission denied.
Show older comments
Hello all,
I'm getting an error sporadically when I'm running my program. I generate multiple plots and save them using a command like:
print('-dpsc2','-r144', [OutputString '_Sinkage_and_Pitch_VS_Ship_Speed'])
Sometime it runs fine, other times I can't get the first plots saved, and other times it stops after a few plots. I just simply run the program again and usually after 2~3 attempts, I don't get an error and it runs just fine. I'm wondering if anyone would have any insight as to why I'm getting this error.
Error:
??? Error using ==> print>LocalPrint at 286 .\RES_A_Total_Resistance_and_Effective_Power_VS_Ship_Speed.ps: Cannot open file: permission denied.
Error in ==> print at 228 LocalPrint(pj);
Thanks.
1 Comment
Daniel Shub
on 17 Oct 2011
Are you printing to a network or external storage drive? Do you have full permissions to the directory? What OS are you using?
Answers (1)
Jason Ross
on 19 Oct 2011
0 votes
I would look into Daniel's permission question, and also check the amount of:
- Temp / swap space on your machine
- Disk space on your machine
- Disk space on the network resource (if you are saving to a network resource)
4 Comments
Peter
on 15 Nov 2011
I've been running into the same problem: code runs fine then fails to print at some (apparently) arbitrary loop cycle. I've run it several times, occassionaly it works and prints through each loop cycle, and then it doesn't. I'm the administrator of the machine; and besides, it works other times just fine.
The error (abridged) is
Error using ==> <a href="matlab: opentoline('C:\~\~\~\~\~\graphics\print.m',325,0)">print at 325</a>
C:\~\~\LOCALS~1\Temp\tp16929d95_5949_4929_b853_6359e964bd51.ps: Cannot open file: permission denied.
and the error occurs when I call the function print with
print(currentfigurehandle, '-dpdf', myfilename);
Here was the most recent 'memstats' prior at the start of the code execution and prior to the error
Physical Memory (RAM):
In Use: 846 MB (34efe000)
Free: 2697 MB (a894c000)
Total: 3544 MB (dd84a000)
Page File (Swap space):
In Use: 732 MB (2dc67000)
Free: 5647 MB (160fcf000)
Total: 6380 MB (18ec36000)
Virtual Memory (Address Space):
In Use: 802 MB (3225e000)
Free: 1245 MB (4dd82000)
Total: 2047 MB (7ffe0000)
Largest Contiguous Free Blocks:
1. [at 2d960000] 787 MB (313a0000)
2. [at 5edcc000] 82 MB ( 5234000)
3. [at 64021000] 47 MB ( 2fdf000)
4. [at 68b40000] 42 MB ( 2aa0000)
5. [at 6fea8000] 27 MB ( 1ba8000)
6. [at 73bc6000] 25 MB ( 19fa000)
7. [at 71ac7000] 21 MB ( 1539000)
8. [at 7e4a1000] 18 MB ( 124f000)
9. [at 7d49c000] 15 MB ( f74000)
10. [at 6ef2d000] 15 MB ( f73000)
======= ==========
1084 MB (43c64000)
and here is the 'memstats' after the error (and browsing the iternet for solutions):
Physical Memory (RAM):
In Use: 1230 MB (4ce1f000)
Free: 2314 MB (90a2b000)
Total: 3544 MB (dd84a000)
Page File (Swap space):
In Use: 1104 MB (4506b000)
Free: 5275 MB (149bcb000)
Total: 6380 MB (18ec36000)
Virtual Memory (Address Space):
In Use: 780 MB (30c8d000)
Free: 1267 MB (4f353000)
Total: 2047 MB (7ffe0000)
Largest Contiguous Free Blocks:
1. [at 2c960000] 803 MB (323a0000)
2. [at 5edcc000] 82 MB ( 5234000)
3. [at 64021000] 47 MB ( 2fdf000)
4. [at 68b40000] 34 MB ( 22d0000)
5. [at 6fea8000] 27 MB ( 1ba8000)
6. [at 73bc6000] 25 MB ( 19fa000)
7. [at 71ac7000] 21 MB ( 1539000)
8. [at 7e4a1000] 18 MB ( 124f000)
9. [at 7d49c000] 15 MB ( f74000)
10. [at 6ef2d000] 15 MB ( f73000)
======= ==========
1092 MB (44494000)
Thanks.
Image Analyst
on 15 Nov 2011
Is "myfilename" different at each iteration through the loop? Did you specify "tp16929d95_5949_4929_b853_6359e964bd51.ps" or is that a name it made up and you actually used something different?
Daniel Shub
on 15 Nov 2011
@Peter, You might be better off posting this as a new question. As for an answer, what are all the ~ doing in the path? I think on Windows the maximum path length + filename length is 255, how long is your path?
Peter
on 15 Nov 2011
@Image Analyst: the file name 'myfilename' does change on each iteration, but the only thing that changes is a few characters (i.e., the path, basic file name format and length, and file extension all remain the same). The post-script file is (AFAIK) a temp file created by the built-in MATLAB function 'print.m' or one of its subfunctions - something I don't have control over. I can't find any similarly-named file on my machine. Note that I'm using the 'recycle off' function at the start of my code, because before I did that similar temporary post-script files were being sent to my recycle bin rather than just being deleted after the .pdf file was created.
@Daniel: I'll try posting as an original question. Per the path issue, I was just trying to eliminate folder names so that just the filename (and not the path) on my computer was visible - sorry if it's not correct computer-ese. Both of those file paths are fine in terms of length; the one is simply where MATLAB installed the built-in 'print.m' file and the other is just a temp folder created by Windows XP (both something I don't have control over).
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!