Python "IOError: [Errno 22] недопустимый аргумент" при использовании cPickle для записи большого массива на сетевой диск

изменить: Себастьяна, я могу получить ту же ошибку гораздо проще:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: open(r'c:test.bin', 'wb').write('a'*67076095)

In [2]: open(r'c:test.bin', 'wb').write('a'*67076096)

In [3]: open(r'z:test.bin', 'wb').write('a'*67076095)

In [4]: open(r'z:test.bin', 'wb').write('a'*67076096)
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

C:Documents and SettingsUser<ipython console> in <module>()

IOError: [Errno 22] Invalid argument

In [5]:

отметим, что C: - это локальный диск, и Z: - это сетевой диск.

ОРИГИНАЛЬНЫЙ ВОПРОС:

Python 2.6.4 в Windows XP аварийно завершает работу, если я использую cPickle для записи файла размером ~67 Мб на наш сетевой диск (ReadyNAS Pro Pioneer edition). Я хотел бы иметь возможность рассолить большие файлы. Это известная проблема? Есть ли обходной путь?

следующий скрипт выдает сбой:

import cPickle, numpy

a = numpy.zeros(8385007)
print "Writing %i bytes..."%(a.nbytes)
cPickle.dump(a, open('test_a.pkl', 'wb'), protocol=2)
print "Successfully written."

b = numpy.zeros(8385008)
print "Writing %i bytes..."%(b.nbytes)
cPickle.dump(b, open('test_b.pkl', 'wb'), protocol=2) ##Crashes on a network drive
print "Successfully written." ##Doesn't crash on a non-network drive

вот шаги, которые я предпринимаю, чтобы произвести сбой в приглашении ipython:

Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

  Welcome to pylab, a matplotlib-based Python environment.
  For more information, type 'help(pylab)'.

In [1]: pwd
Out[1]: 'C:Documents and SettingsUser'

In [2]: run test
Writing 67080056 bytes...
Successfully written.
Writing 67080064 bytes...
Successfully written.

In [3]: cd Z:
Z:

In [4]: pwd
Out[4]: 'Z:'

In [5]: run 'C:Documents and SettingsUsertest'
Writing 67080056 bytes...
Successfully written.
Writing 67080064 bytes...
---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)

C:Documents and SettingsUsertest.py in <module>()
      8 b = numpy.zeros(8385008)
      9 print "Writing %i bytes..."%(b.nbytes)
---> 10 cPickle.dump(b, open('test_b.pkl', 'wb'), protocol=2)
     11 print "Successfully written."
     12

IOError: [Errno 22] Invalid argument
WARNING: Failure executing file: <C:Documents and SettingsUsertest.py>

In [6]:

C: является локальным жестким диском на машине. Z: это наше сетевое хранилище.

1 ответов


Я считаю, что проблема связана с: http://support.microsoft.com/default.aspx?scid=kb; en-us;899149

...Итак, просто попробуйте: открыть(r'z:\test - ... bin', 'w+b').написать ('a' *67080064)

*обратите внимание на аргумент: 'w+b'