I am using put from pysftp to upload some files to a SFTP server.
I have a Python list filesToUpload_bordet and I am uploading each file x using a for loop within a context manager, as shown below:
# Enter the sftp server and perform the operations
with pysftp.Connection(host=hostname,
username=username,
password=password) as sftp:
# Create and cd to the directory where the files will be uploaded
try:
sftp.mkdir(f'{lastRun}')
except OSError:
append(line=f"{timeStamp} run {lastRun}: {panel} WARNING: sftp directory /ngs/{lastRun} already exists, so not creating\n",logFile=logFile)
with sftp.cd(f'/ngs/{lastRun}'):
for x in filesToUpload_bordet:
# put the vcf files
sftp.put(x)
I know that the snipped above works because the upload successfully started. Though, after sometime I am getting the following error message on the Python console:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/nexus/databases/ngsRunStats_FK/postPipeline/scripts/newStrategy/STEPS_postPipeline_prod.py in <module>
----> 1 sftpUpload(panel)
/nexus/databases/ngsRunStats_FK/postPipeline/scripts/newStrategy/STEPS_postPipeline_prod.py in sftpUpload(panel)
1212 for x in filesToUpload_bordet:
1213 # put the vcf files
---> 1214 sftp.put(x)
1215 sftp.close() # this is probably not necessary as I am working on a context manager
1216 # this message should be sent independently from the coverage check email
~/miniconda3/lib/python3.7/site-packages/pysftp/__init__.py in put(self, localpath, remotepath, callback, confirm, preserve_mtime)
362
363 sftpattrs = self._sftp.put(localpath, remotepath, callback=callback,
--> 364 confirm=confirm)
365 if preserve_mtime:
366 self._sftp.utime(remotepath, times)
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_client.py in put(self, localpath, remotepath, callback, confirm)
757 file_size = os.stat(localpath).st_size
758 with open(localpath, "rb") as fl:
--> 759 return self.putfo(fl, remotepath, file_size, callback, confirm)
760
761 def getfo(self, remotepath, fl, callback=None):
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_client.py in putfo(self, fl, remotepath, file_size, callback, confirm)
715 fr.set_pipelined(True)
716 size = self._transfer_with_callback(
--> 717 reader=fl, writer=fr, file_size=file_size, callback=callback
718 )
719 if confirm:
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_client.py in _transfer_with_callback(self, reader, writer, file_size, callback)
677 while True:
678 data = reader.read(32768)
--> 679 writer.write(data)
680 size += len(data)
681 if len(data) == 0:
~/miniconda3/lib/python3.7/site-packages/paramiko/file.py in write(self, data)
403 raise IOError("File not open for writing")
404 if not (self._flags & self.FLAG_BUFFERED):
--> 405 self._write_all(data)
406 return
407 self._wbuffer.write(data)
~/miniconda3/lib/python3.7/site-packages/paramiko/file.py in _write_all(self, data)
520 # a socket).
521 while len(data) > 0:
--> 522 count = self._write(data)
523 data = data[count:]
524 if self._flags & self.FLAG_APPEND:
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_file.py in _write(self, data)
206 while len(self._reqs):
207 req = self._reqs.popleft()
--> 208 t, msg = self.sftp._read_response(req)
209 if t != CMD_STATUS:
210 raise SFTPError("Expected status")
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_client.py in _read_response(self, waitfor)
863 # synchronous
864 if t == CMD_STATUS:
--> 865 self._convert_status(msg)
866 return t, msg
867
~/miniconda3/lib/python3.7/site-packages/paramiko/sftp_client.py in _convert_status(self, msg)
896 raise IOError(errno.EACCES, text)
897 else:
--> 898 raise IOError(text)
899
900 def _adjust_cwd(self, path):
OSError: Failure
Can this be anything other than a time-out issue? I see that my first file was successfully uploaded at 09:08am and I got the error message at 11:49am.
The "Failure" is an error message for SFTP error code 4, returned by the OpenSSH SFTP server for various problems, for which there's no more specific code in the SFTP protocol version 3. While the server should at least return a specific plain-text error message, it fails to do so.
Common reasons you may get the generic "Failure" error message, while uploading are:
Uploading a file to a full filesystem (HDD).
Exceeding a user disk quota.
For details, see SFTP Status/Error Code 4 (Failure).
Related
I was working just fine with Google Colaboratory and suddenly this error started to pop up each time I try to load any type of file. It first started when I was trying to read an hdf file, now everything won't open.
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-8-65c4e8d1c435> in <module>()
----> 1 eo=EOPatch.load('./20.Clean_Textural_features/eopatch_0')
2 eo
9 frames
/usr/local/lib/python3.6/dist-packages/eolearn/core/eodata.py in load(path, features, lazy_loading, filesystem)
530 path = '/'
531
--> 532 return load_eopatch(EOPatch(), filesystem, path, features=features, lazy_loading=lazy_loading)
533
534 def time_series(self, ref_date=None, scale_time=1):
/usr/local/lib/python3.6/dist-packages/eolearn/core/eodata_io.py in load_eopatch(eopatch, filesystem, patch_location, features, lazy_loading)
76 loading_data = executor.map(lambda loader: loader.load(), loading_data)
77
---> 78 for (ftype, fname, _), value in zip(features, loading_data):
79 eopatch[(ftype, fname)] = value
80
/usr/lib/python3.6/concurrent/futures/_base.py in result_iterator()
584 # Careful not to keep a reference to the popped future
585 if timeout is None:
--> 586 yield fs.pop().result()
587 else:
588 yield fs.pop().result(end_time - time.monotonic())
/usr/lib/python3.6/concurrent/futures/_base.py in result(self, timeout)
423 raise CancelledError()
424 elif self._state == FINISHED:
--> 425 return self.__get_result()
426
427 self._condition.wait(timeout)
/usr/lib/python3.6/concurrent/futures/_base.py in __get_result(self)
382 def __get_result(self):
383 if self._exception:
--> 384 raise self._exception
385 else:
386 return self._result
/usr/lib/python3.6/concurrent/futures/thread.py in run(self)
54
55 try:
---> 56 result = self.fn(*self.args, **self.kwargs)
57 except BaseException as exc:
58 self.future.set_exception(exc)
/usr/local/lib/python3.6/dist-packages/eolearn/core/eodata_io.py in <lambda>(loader)
74 if not lazy_loading:
75 with concurrent.futures.ThreadPoolExecutor() as executor:
---> 76 loading_data = executor.map(lambda loader: loader.load(), loading_data)
77
78 for (ftype, fname, _), value in zip(features, loading_data):
/usr/local/lib/python3.6/dist-packages/eolearn/core/eodata_io.py in load(self)
217 return self._decode(gzip_fp, self.path)
218
--> 219 return self._decode(file_handle, self.path)
220
221 def save(self, data, file_format, compress_level=0):
/usr/local/lib/python3.6/dist-packages/eolearn/core/eodata_io.py in _decode(file, path)
268
269 if FileFormat.NPY.extension() in path:
--> 270 return np.load(file)
271
272 raise ValueError('Unsupported data type.')
/usr/local/lib/python3.6/dist-packages/numpy/lib/npyio.py in load(file, mmap_mode, allow_pickle, fix_imports, encoding)
434 _ZIP_SUFFIX = b'PK\x05\x06' # empty zip files start with this
435 N = len(format.MAGIC_PREFIX)
--> 436 magic = fid.read(N)
437 # If the file size is less than N, we need to make sure not
438 # to seek past the beginning of the file
OSError: [Errno 5] Input/output error
Also some notebooks won't open and this appears instead:
I looked around at similar posts here, but didn't understand anything. Therefore, any help would be highly appreciated.
PS: my files are in subfolders and not directly contained in 'My Drive'. I have a lso disabled all the adblocks ad the problem persists...
I think the file/link has been used for downloading beyond its weekly limit. This answer may help you.
Some discussion about Google's policy on hosting data on drive.
The solution is to wait for couple of hours/days and try again.
I am attempting to connect to Neo4j but I keep getting this error. I tried
from neo4j.v1 import GraphDatabase
driver = GraphDatabase.driver(uri="bolt://localhost:7687", auth=("neo4j", "12345"))
but I get this error when I try to connect
SecurityError: Failed to establish secure connection to 'EOF occurred in violation of protocol (_ssl.c:841)'
I can connect to the browser when I type http://localhost:7474/browser/
Here is the full error log:
--------------------------------------------------------------------------- SSLEOFError Traceback (most recent call
last)
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
_secure(s, host, ssl_context, **config)
853 try:
--> 854 s = ssl_context.wrap_socket(s, server_hostname=host if HAS_SNI and host else None)
855 except SSLError as cause:
c:\program files\python36\lib\ssl.py in wrap_socket(self, sock,
server_side, do_handshake_on_connect, suppress_ragged_eofs,
server_hostname, session)
406 server_hostname=server_hostname,
--> 407 _context=self, _session=session)
408
c:\program files\python36\lib\ssl.py in init(self, sock, keyfile,
certfile, server_side, cert_reqs, ssl_version, ca_certs,
do_handshake_on_connect, family, type, proto, fileno,
suppress_ragged_eofs, npn_protocols, ciphers, server_hostname,
_context, _session)
813 raise ValueError("do_handshake_on_connect should not be specified for
non-blocking sockets")
--> 814 self.do_handshake()
815
c:\program files\python36\lib\ssl.py in do_handshake(self, block)
1067 self.settimeout(None)
-> 1068 self._sslobj.do_handshake() 1069 finally:
c:\program files\python36\lib\ssl.py in do_handshake(self)
688 """Start the SSL/TLS handshake."""
--> 689 self._sslobj.do_handshake()
690 if self.context.check_hostname:
SSLEOFError: EOF occurred in violation of protocol (_ssl.c:841)
The above exception was the direct cause of the following exception:
SecurityError Traceback (most recent call
last) in
1
----> 2 driver = GraphDatabase.driver(uri="bolt://localhost:7687", auth=("neo4j", "12345"))
~\AppData\Roaming\Python\Python36\site-packages\neo4j__init__.py in
driver(cls, uri, **config)
118 :class:.Driver subclass instance directly.
119 """
--> 120 return Driver(uri, **config)
121
122
~\AppData\Roaming\Python\Python36\site-packages\neo4j__init__.py in
new(cls, uri, **config)
159 for subclass in Driver.subclasses():
160 if parsed_scheme in subclass.uri_schemes:
--> 161 return subclass(uri, **config)
162 raise ValueError("URI scheme %r not supported" % parsed.scheme)
163
~\AppData\Roaming\Python\Python36\site-packages\neo4j__init__.py in
new(cls, uri, **config)
233
234 pool = ConnectionPool(connector, instance.address, **config)
--> 235 pool.release(pool.acquire())
236 instance._pool = pool
237 instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"])
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
acquire(self, access_mode)
713
714 def acquire(self, access_mode=None):
--> 715 return self.acquire_direct(self.address)
716
717
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
acquire_direct(self, address)
606 if can_create_new_connection:
607 try:
--> 608 connection = self.connector(address, error_handler=self.connection_error_handler)
609 except ServiceUnavailable:
610 self.remove(address)
~\AppData\Roaming\Python\Python36\site-packages\neo4j__init__.py in
connector(address, **kwargs)
230
231 def connector(address, **kwargs):
--> 232 return connect(address, **dict(config, **kwargs))
233
234 pool = ConnectionPool(connector, instance.address, **config)
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
connect(address, **config)
970 raise ServiceUnavailable("Failed to resolve addresses for %s" % address)
971 else:
--> 972 raise last_error
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
connect(address, **config)
961 host = address[0]
962 s = _connect(resolved_address, **config)
--> 963 s, der_encoded_server_certificate = _secure(s, host, security_plan.ssl_context, **config)
964 connection = _handshake(s, address, der_encoded_server_certificate, **config)
965 except Exception as error:
~\AppData\Roaming\Python\Python36\site-packages\neobolt\direct.py in
_secure(s, host, ssl_context, **config)
857 error = SecurityError("Failed to establish secure connection to {!r}".format(cause.args[1]))
858 error.cause = cause
--> 859 raise error
860 else:
861 # Check that the server provides a certificate
SecurityError: Failed to establish secure connection to 'EOF occurred
in violation of protocol (_ssl.c:841)'
I found the solution for people who might have the same issue. You need to add encrypted=False.
Instead of
from neo4j.v1 import GraphDatabase
driver = GraphDatabase.driver(uri="bolt://localhost:7687", auth=("neo4j", "12345"))
it should be:
driver = GraphDatabase.driver(uri="bolt://localhost:7687", auth=("neo4j", "12345"), encrypted=False)
Hope this will help someone
I had the same problem with the Object Graph Mapper Neomodel (connecting to neo4j v4). Adding the second line solved it:
config.DATABASE_URL = 'bolt://neo4j:password123#localhost:7687'
config.ENCRYPTED_CONNECTION = False
had the same issue, answer from Sam did not resolve it, however. Using
from neo4j import GraphDatabase
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver( encrypted=False, uri, auth=('neo4j', 'asdf'))
I get the error SyntaxError: positional argument follows keyword argument
typing the uridirectly into the command like this: driver = GraphDatabase.driver( encrypted=False, uri = "bolt://localhost:7687", auth=('neo4j', 'asdf')) resulted in another error (SecurityError: Failed to establish secure connection to '[SSL: KRB5_S_TKT_NYV] unexpected eof while reading (_ssl.c:1076)')
When following a post in the neo4j community however, they switch positions of the arguments to this:
from neo4j import GraphDatabase
uri = "bolt://localhost:7687"
driver = GraphDatabase.driver( uri, auth=('neo4j', 'asdf')encrypted=False)
it works like a charm.
I am running a python script in Jupyter Notebook that connects to a mongo db to process text documents (news articles). The script runs fine for the first few batches of data, but then terminates with the following error:
AutoReconnect: localhost:27017: [WinError 10054] An existing connection was forcibly closed by the remote host (full error below).
Have already tried deleting the mongod.lock file as prescribed here(Pymongo keeps refusing the connection at 27017), however, this hasn't solved the issue.
This is my function (with a few sub-functions as well not included here):
data_list = []
for collection in mongo_collections_dir:
mongo_collection = mongo_collections_dir[collection]
filter_dict = {"file_info.source": source}
if filter_year:
filter_dict["extracted.publication_date.year"] = filter_year
elif min_year:
print('filter year not found') # - note added by dror for debug 24/10/2019
filter_dict["extracted.publication_date.year"] = {"$gt": min_year}
source_count = mongo_collection.count(filter_dict)
print("{} articles found in collection {} {}".format(source_count, collection, filter_year))
if source_count == "0":
continue
docs = mongo_collection.find(filter_dict, no_cursor_timeout=True)
if not docs:
print("source {} was not found in collection {}".format(source, collection))
continue
for pos, doc in enumerate(docs):
if pos % 100000 == 0:
print("processed {} articles out of {} from {}".format(pos, source_count, source))
try:
text = doc["body"]["content"]
except KeyError:
# print('no body')
continue
if clean_text:
clean_text = mpd_clean_text(text, stop_words)
else:
clean_text = ''
try:
title = doc['body']['head']['hedline']
# author = doc['body']['head']['byline']
temp_dir = {"collection": mongo_collection.name, "source": doc["file_info"]["source"],
"urn": doc["urn"], "title": title,
'unit_text': text, 'clean text': clean_text,
}
except KeyError:
temp_dir = {"collection": mongo_collection.name, "source": doc["file_info"]["source"], "urn": doc["urn"],
'unit_text': text, 'clean text': clean_text}
try:
publication_date = get_dt(doc["extracted"]["publication_date"])
temp_dir['publication_date'] = publication_date
except KeyError:
print('no extracted')
try:
temp_dir['section'] = doc['extracted']['section']
except KeyError:
pass
try:
temp_dir['publication_name'] = doc['extracted']['publication_name']
except KeyError:
pass
if temp_dir:
# temp_dir['section'] = section
data_list.append(temp_dir)
# df = pd.DataFrame(data_list)
# df['section'] = section
return pd.DataFrame(data_list)
Full error:
~\Anaconda3\envs\py35\lib\site-packages\pymongo\pool.py in command(self, dbname, spec, slave_ok, read_preference, codec_options, check, allowable_errors, check_keys, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events)
578 use_op_msg=self.op_msg_enabled,
--> 579 unacknowledged=unacknowledged)
580 except OperationFailure:
~\Anaconda3\envs\py35\lib\site-packages\pymongo\network.py in command(sock, dbname, spec, slave_ok, is_mongos, read_preference, codec_options, session, client, check, allowable_errors, address, check_keys, listeners, max_bson_size, read_concern, parse_write_concern_error, collation, compression_ctx, use_op_msg, unacknowledged)
140 else:
--> 141 reply = receive_message(sock, request_id)
142 unpacked_docs = reply.unpack_response(codec_options=codec_options)
~\Anaconda3\envs\py35\lib\site-packages\pymongo\network.py in receive_message(sock, request_id, max_message_size)
172 length, _, response_to, op_code = _UNPACK_HEADER(
--> 173 _receive_data_on_socket(sock, 16))
174 # No request_id for exhaust cursor "getMore".
~\Anaconda3\envs\py35\lib\site-packages\pymongo\network.py in _receive_data_on_socket(sock, length)
231 try:
--> 232 chunk_length = sock.recv_into(mv[bytes_read:])
233 except (IOError, OSError) as exc:
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
During handling of the above exception, another exception occurred:
AutoReconnect Traceback (most recent call last)
<ipython-input-14-37a7effc9859> in <module>
----> 1 collect_df_by_sources(collections_dir, sources, newspapers_df, filter_year='2008')
<ipython-input-8-bbd9e966e95c> in collect_df_by_sources(collections_dir, sources, newspapers_df, return_df, filter_year, min_year, override)
20
21 print("collect articles from: {}, {}".format(source_name, source_id))
---> 22 source_df = collect_df_by_source(collections_dir, source_id, filter_year=filter_year, min_year=min_year)
23 source_df.to_csv(source_path, encoding='utf8')
24 if return_df:
<ipython-input-7-82d129ff329c> in collect_df_by_source(mongo_collections_dir, source, clean_text, filter_year, min_year)
9 print('filter year not found') # - note added by dror for debug 24/10/2019
10 filter_dict["extracted.publication_date.year"] = {"$gt": min_year}
---> 11 source_count = mongo_collection.count(filter_dict)
12 print("{} articles found in collection {} {}".format(source_count, collection, filter_year))
13 if source_count == "0":
~\Anaconda3\envs\py35\lib\site-packages\pymongo\collection.py in count(self, filter, session, **kwargs)
1764 collation = validate_collation_or_none(kwargs.pop('collation', None))
1765 cmd.update(kwargs)
-> 1766 return self._count(cmd, collation, session)
1767
1768 def create_indexes(self, indexes, session=None, **kwargs):
~\Anaconda3\envs\py35\lib\site-packages\pymongo\collection.py in _count(self, cmd, collation, session)
1570 read_concern=self.read_concern,
1571 collation=collation,
-> 1572 session=session)
1573 if res.get("errmsg", "") == "ns missing":
1574 return 0
~\Anaconda3\envs\py35\lib\site-packages\pymongo\collection.py in _command(self, sock_info, command, slave_ok, read_preference, codec_options, check, allowable_errors, read_concern, write_concern, collation, session, retryable_write)
242 session=s,
243 client=self.__database.client,
--> 244 retryable_write=retryable_write)
245
246 def __create(self, options, collation, session):
~\Anaconda3\envs\py35\lib\site-packages\pymongo\pool.py in command(self, dbname, spec, slave_ok, read_preference, codec_options, check, allowable_errors, check_keys, read_concern, write_concern, parse_write_concern_error, collation, session, client, retryable_write, publish_events)
582 # Catch socket.error, KeyboardInterrupt, etc. and close ourselves.
583 except BaseException as error:
--> 584 self._raise_connection_failure(error)
585
586 def send_message(self, message, max_doc_size):
~\Anaconda3\envs\py35\lib\site-packages\pymongo\pool.py in _raise_connection_failure(self, error)
741 self.close()
742 if isinstance(error, socket.error):
--> 743 _raise_connection_failure(self.address, error)
744 else:
745 raise error
~\Anaconda3\envs\py35\lib\site-packages\pymongo\pool.py in _raise_connection_failure(address, error, msg_prefix)
281 raise NetworkTimeout(msg)
282 else:
--> 283 raise AutoReconnect(msg)
284
285
AutoReconnect: localhost:27017: [WinError 10054] An existing connection was forcibly closed by the remote host```
I am working on a Jupyter notebook server remotely and when I create a file using:
file = open("test.txt","w") file.write("test") file.close()
Everything works as expected and the file test.txt is written to the working directory. My problem arises wh trying to use the the Pandas to_hfs command:
data.to_hdf('raw_data.h5','raw_data_santodomingo',mode='w',format='f',data_columns=True)
I get the following error:
Opening raw_data.h5 in read-only mode
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in open(self, mode, **kwargs)
586 try:
--> 587 self._handle = tables.open_file(self._path, self._mode, **kwargs)
588 except (IOError) as e: # pragma: no cover
/opt/conda/lib/python3.6/site-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
319 # Finally, create the File instance, and return it
--> 320 return File(filename, mode, title, root_uep, filters, **kwargs)
321
/opt/conda/lib/python3.6/site-packages/tables/file.py in __init__(self, filename, mode, title, root_uep, filters, **kwargs)
783 # Now, it is time to initialize the File extension
--> 784 self._g_new(filename, mode, **params)
785
tables/hdf5extension.pyx in tables.hdf5extension.File._g_new()
/opt/conda/lib/python3.6/site-packages/tables/utils.py in check_file_access(filename, mode)
178 raise IOError("directory ``%s`` exists but it can not be "
--> 179 "written" % (parentname,))
180 elif mode == 'a':
OSError: directory ``.`` exists but it can not be written
During handling of the above exception, another exception occurred:
OSError Traceback (most recent call last)
<ipython-input-182-479f2e98ea81> in <module>()
----> 1 pre_clean_data.to_hdf('raw_data.h5','raw_data_santodomingo',mode='w',format='f',data_columns=True)
/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in to_hdf(self, path_or_buf, key, **kwargs)
1136
1137 from pandas.io import pytables
-> 1138 return pytables.to_hdf(path_or_buf, key, self, **kwargs)
1139
1140 def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs):
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in to_hdf(path_or_buf, key, value, mode, complevel, complib, append, **kwargs)
267 if isinstance(path_or_buf, string_types):
268 with HDFStore(path_or_buf, mode=mode, complevel=complevel,
--> 269 complib=complib) as store:
270 f(store)
271 else:
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
446 self._fletcher32 = fletcher32
447 self._filters = None
--> 448 self.open(mode=mode, **kwargs)
449
450 #property
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in open(self, mode, **kwargs)
589 if 'can not be written' in str(e):
590 print('Opening %s in read-only mode' % self._path)
--> 591 self._handle = tables.open_file(self._path, 'r', **kwargs)
592 else:
593 raise
/opt/conda/lib/python3.6/site-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
318
319 # Finally, create the File instance, and return it
--> 320 return File(filename, mode, title, root_uep, filters, **kwargs)
321
322
/opt/conda/lib/python3.6/site-packages/tables/file.py in __init__(self, filename, mode, title, root_uep, filters, **kwargs)
782
783 # Now, it is time to initialize the File extension
--> 784 self._g_new(filename, mode, **params)
785
786 # Check filters and set PyTables format version for new files.
tables/hdf5extension.pyx in tables.hdf5extension.File._g_new()
/opt/conda/lib/python3.6/site-packages/tables/utils.py in check_file_access(filename, mode)
154 # The file should be readable.
155 if not os.access(filename, os.F_OK):
--> 156 raise IOError("``%s`` does not exist" % (filename,))
157 if not os.path.isfile(filename):
158 raise IOError("``%s`` is not a regular file" % (filename,))
OSError: ``raw_data.h5`` does not exist
These lines seem pertinent and are making me think write permission is the issue:
/opt/conda/lib/python3.6/site-packages/tables/utils.py in check_file_access(filename, mode)
154 # The file should be readable.
155 if not os.access(filename, os.F_OK):
--> 156 raise IOError("``%s`` does not exist" % (filename,))
157 if not os.path.isfile(filename):
158 raise IOError("``%s`` is not a regular file" % (filename,))
And
/opt/conda/lib/python3.6/site-packages/tables/utils.py in check_file_access(filename, mode)
154 # The file should be readable.
155 if not os.access(filename, os.F_OK):
--> 156 raise IOError("``%s`` does not exist" % (filename,))
157 if not os.path.isfile(filename):
158 raise IOError("``%s`` is not a regular file" % (filename,))
OSError: ``raw_data.h5`` does not exist
However that would confuse me as I can write text files in the working directory as mentioned above. All and any attempts at assistance appreciated.
EDIT: If i use the full path :/home/joyvan/work/raw_data.h5' I get a different error readout.
data.to_hdf('/home/joyvan/work/raw_data.h5','raw_data_santodomingo',mode='w',format='f',data_columns=True)
produces
OSError Traceback (most recent call last)
<ipython-input-185-de493145e6a7> in <module>()
----> 1 pre_clean_data.to_hdf('/home/joyvan/work/raw_data.h5','raw_data_santodomingo',mode='w',format='f',data_columns=True)
/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in to_hdf(self, path_or_buf, key, **kwargs)
1136
1137 from pandas.io import pytables
-> 1138 return pytables.to_hdf(path_or_buf, key, self, **kwargs)
1139
1140 def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs):
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in to_hdf(path_or_buf, key, value, mode, complevel, complib, append, **kwargs)
267 if isinstance(path_or_buf, string_types):
268 with HDFStore(path_or_buf, mode=mode, complevel=complevel,
--> 269 complib=complib) as store:
270 f(store)
271 else:
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
446 self._fletcher32 = fletcher32
447 self._filters = None
--> 448 self.open(mode=mode, **kwargs)
449
450 #property
/opt/conda/lib/python3.6/site-packages/pandas/io/pytables.py in open(self, mode, **kwargs)
585
586 try:
--> 587 self._handle = tables.open_file(self._path, self._mode, **kwargs)
588 except (IOError) as e: # pragma: no cover
589 if 'can not be written' in str(e):
/opt/conda/lib/python3.6/site-packages/tables/file.py in open_file(filename, mode, title, root_uep, filters, **kwargs)
318
319 # Finally, create the File instance, and return it
--> 320 return File(filename, mode, title, root_uep, filters, **kwargs)
321
322
/opt/conda/lib/python3.6/site-packages/tables/file.py in __init__(self, filename, mode, title, root_uep, filters, **kwargs)
782
783 # Now, it is time to initialize the File extension
--> 784 self._g_new(filename, mode, **params)
785
786 # Check filters and set PyTables format version for new files.
tables/hdf5extension.pyx in tables.hdf5extension.File._g_new()
/opt/conda/lib/python3.6/site-packages/tables/utils.py in check_file_access(filename, mode)
172 parentname = '.'
173 if not os.access(parentname, os.F_OK):
--> 174 raise IOError("``%s`` does not exist" % (parentname,))
175 if not os.path.isdir(parentname):
176 raise IOError("``%s`` is not a directory" % (parentname,))
OSError: ``/home/joyvan/work`` does not exist
I ran into similar problem for this.
It turns out that as a current user i am running file does not have enough permission to write.
I ran same script with root user and it worked.
Note: This is late and not an answer to OP's Questions but similar situation for me and writing solution which worked for me.
I want to test the value of redis can support up to 512MB
language:python
import redis
conn = redis.Redis()
temp_dict={}
for i in range(1000000):
temp_dict.update({str(i):str(i)})
conn.hmset('hash-key',temp_dict)
errors:
---------------------------------------------------------------------------
ConnectionError Traceback (most recent call last)
in ()
----> 1 conn.hmset('hash-key',temp_dict)
/usr/local/lib/python2.7/dist-packages/redis/client.pyc in hmset(self, name, mapping)
2009 for pair in iteritems(mapping):
2010 items.extend(pair)
-> 2011 return self.execute_command('HMSET', name, *items)
2012
2013 def hmget(self, name, keys, *args):
/usr/local/lib/python2.7/dist-packages/redis/client.pyc in execute_command(self, *args, **options)
671 if not connection.retry_on_timeout and isinstance(e, TimeoutError):
672 raise
--> 673 connection.send_command(*args)
674 return self.parse_response(connection, command_name, **options)
675 finally:
/usr/local/lib/python2.7/dist-packages/redis/connection.pyc in send_command(self, *args)
608 def send_command(self, *args):
609 "Pack and send a command to the Redis server"
--> 610 self.send_packed_command(self.pack_command(*args))
611
612 def can_read(self, timeout=0):
/usr/local/lib/python2.7/dist-packages/redis/connection.pyc in send_packed_command(self, command)
601 errmsg = e.args[1]
602 raise ConnectionError("Error %s while writing to socket. %s." %
--> 603 (errno, errmsg))
604 except:
605 self.disconnect()
ConnectionError: Error 104 while writing to socket. Connection reset by peer.
Maybe the data inserted at one time is too large, and the data can be separated and only 100000 pieces can be hmset at a time。
import redis
conn = redis.Redis()
for x in range(10):
temp_dict={}
for i in range(100000):
temp_dict.update({str(i):str(i)})
conn.hmset('hash-key',temp_dict)