On my windows,
pathlib.Path('R:/人')
has no problem to give
WindowsPath('R:/人')
However,
pathlib.Path('R:/人').resolve()
gives
--------------------------------------------------------------------------- OSError Traceback (most recent call
last) in
----> 1 pathlib.Path('R:/人').resolve()
~\anaconda3\lib\pathlib.py in resolve(self, strict) 1178 if
self._closed: 1179 self._raise_closed()
-> 1180 s = self._flavour.resolve(self, strict=strict) 1181 if s is None: 1182 # No symlink resolution => for
consistency, raise an error if
~\anaconda3\lib\pathlib.py in resolve(self, path, strict)
203 while True:
204 try:
--> 205 s = self._ext_to_normal(_getfinalpathname(s))
206 except FileNotFoundError:
207 previous_s = s
OSError: [WinError 1] 函数不正确。: 'R:\人'
What is the problem with resolve in pathlib?
On the other hand,
pathlib.Path('R:/人').absolute()
correctly gives
WindowsPath('R:/人')
Related
I want to read a pickle file into a data frame. However, I get the following error message and I don't know how to solve the issue.
df_batches = pd.read_pickle(folder_in / "batches_and_phases.p")
Error Message:
AttributeError Traceback (most recent call last)
File ~\Master_Thesis\mypython\lib\site-packages\pandas\io\pickle.py:205, in read_pickle(filepath_or_buffer, compression, storage_options)
204 warnings.simplefilter("ignore", Warning)
--> 205 return pickle.load(handles.handle)
206 except excs_to_catch:
207 # e.g.
208 # "No module named 'pandas.core.sparse.series'"
209 # "Can't get attribute '__nat_unpickle' on <module 'pandas._libs.tslib"
File ~\Master_Thesis\mypython\lib\site-packages\pandas\_libs\internals.pyx:750, in pandas._libs.internals.BlockManager.__setstate__()
File ~\Master_Thesis\mypython\lib\site-packages\pandas\_libs\internals.pyx:767, in pandas._libs.internals.BlockManager.__setstate__()
File ~\Master_Thesis\mypython\lib\site-packages\pandas\core\internals\blocks.py:2143, in ensure_block_shape(values, ndim)
2142 if values.ndim < ndim:
-> 2143 if not is_1d_only_ea_dtype(values.dtype):
2144 # TODO(EA2D): https://github.com/pandas-dev/pandas/issues/23023
2145 # block.shape is incorrect for "2D" ExtensionArrays
2146 # We can't, and don't need to, reshape.
2147 values = cast("np.ndarray | DatetimeArray | TimedeltaArray", values)
File ~\Master_Thesis\mypython\lib\site-packages\pandas\core\arrays\interval.py:624, in IntervalArray.dtype(self)
622 #property
623 def dtype(self) -> IntervalDtype:
--> 624 return self._dtype
AttributeError: 'IntervalArray' object has no attribute '_dtype'
Thank you!
Hi i am having issues with loading the .s2p file
when i ran the following code
import skrf as rf
from skrf import Network, Frequency
data1 = rf.Network('/Users/pradeeps/Desktop/Project/meas2018_07_06/300MHzNLOSX1DPS.s2p')
It showed the following error as shown below
---------------------------------------------------------------------------
UnpicklingError Traceback (most recent call last)
File ~/Desktop/Project/project/lib/python3.10/site-packages/skrf/network.py:450, in Network.__init__(self, file, name, params, comments, f_unit, s_def, **kwargs)
449 try:
--> 450 self.read(fid)
451 except UnicodeDecodeError: # Support for pickles created in Python2 and loaded in Python3
File ~/Desktop/Project/project/lib/python3.10/site-packages/skrf/network.py:2357, in Network.read(self, *args, **kwargs)
2356 from .io.general import read
-> 2357 self.copy_from(read(*args, **kwargs))
File ~/Desktop/Project/project/lib/python3.10/site-packages/skrf/io/general.py:140, in read(file, *args, **kwargs)
139 try:
--> 140 obj = pickle.load(fid, *args, **kwargs)
141 except (UnpicklingError, UnicodeDecodeError) as e:
142 # if fid is seekable then reset to beginning of file
UnpicklingError: invalid load key, '3'.
During handling of the above exception, another exception occurred:
NotImplementedError Traceback (most recent call last)
Untitled-1.ipynb Cell 2' in <cell line: 1>()
----> 1 data1 = rf.Network('/Users/pradeeps/Desktop/Project/meas2018_07_06/300MHzNLOSX1DPS.s2p')
File ~/Desktop/Project/project/lib/python3.10/site-packages/skrf/network.py:458, in Network.__init__(self, file, name, params, comments, f_unit, s_def, **kwargs)
456 filename = fid.name
457 fid.close()
--> 458 self.read_touchstone(filename, self.encoding)
460 if name is None and isinstance(file, str):
461 name = os.path.splitext(os.path.basename(file))[0]
File ~/Desktop/Project/project/lib/python3.10/site-packages/skrf/network.py:1956, in Network.read_touchstone(self, filename, encoding)
1953 touchstoneFile = touchstone.Touchstone(filename, encoding=encoding)
1955 if touchstoneFile.get_format().split()[1] != 's':
-> 1956 raise NotImplementedError('only s-parameters supported for now.')
1958 self.comments = touchstoneFile.get_comments()
1960 try:
NotImplementedError: only s-parameters supported for now.
As shown in this particular code i used scikit-rf is there any other package that i should use in this particular instance or am i doing anything wrong.
Thank you
I have set up ad manager credentials. I'm trying to access the Admanager API, im getting the following error.
from googleads import ad_manager
client = ad_manager.AdManagerClient.LoadFromStorage()
network_service = client.GetService('NetworkService', version='v201902')
current_network = network_service.getCurrentNetwork()
the error im facing is:
Fault Traceback (most recent call last)
~\Anaconda3\lib\site-packages\googleads\common.py in MakeSoapRequest(*args)
1381 return soap_service_method(
-> 1382 *packed_args, _soapheaders=soap_headers)['body']['rval']
1383 except zeep.exceptions.Fault as e:
~\Anaconda3\lib\site-packages\zeep\proxy.py in __call__(self, *args, **kwargs)
41 self._proxy._client, self._proxy._binding_options,
---> 42 self._op_name, args, kwargs)
43
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in send(self, client, options, operation, args, kwargs)
131
--> 132 return self.process_reply(client, operation_obj, response)
133
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in process_reply(self, client, operation, response)
193 if response.status_code != 200 or fault_node is not None:
--> 194 return self.process_error(doc, operation)
195
~\Anaconda3\lib\site-packages\zeep\wsdl\bindings\soap.py in process_error(self, doc, operation)
287 actor=None,
--> 288 detail=etree_to_string(doc))
289
Fault: Unknown fault occured
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
<ipython-input-16-991c0839fc99> in <module>()
----> 1 current_network = network_service.getCurrentNetwork()
~\Anaconda3\lib\site-packages\googleads\common.py in MakeSoapRequest(*args)
1385 if e.detail is not None:
1386 underlying_exception = e.detail.find(
-> 1387 '{%s}ApiExceptionFault' % self._GetBindingNamespace())
1388 fault_type = self.zeep_client.get_element(
1389 '{%s}ApiExceptionFault' % self._GetBindingNamespace())
TypeError: a bytes-like object is required, not 'str'
You are probably missing permissions with your configured service account. Make sure the account has access to ad-manager and scopes are configured properly.
I suggest to do it this way:
class Adx:
def __init__(self):
self.GOOGLEADS_YAML = 'googleads.yaml'
self.GOOGLEADS_VERSION = 'v202111'
self.google_keys = self.GOOGLEADS_YAML
def activate(self):
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage(self.google_keys)
I am trying to convert an Audio file to text . Audio is saved as Wel.wav in my desktop.
Below is the code:
import speech_recognition as sr
r = sr.Recognizer()
audio = 'Wel.wav'
with sr.AudioFile(audio) as source:
audio = r.record(source)
print ('Done!')
try:
text = r.recognize_google(audio)
print (text)
except Exception as e:
print (e)
I am getting the below error:
FileNotFoundError Traceback (most recent call last)
<ipython-input-27-432c6c552a8c> in <module>()
5 audio = 'Wel.wav'
6
----> 7 with sr.AudioFile(audio) as source:
8 audio = r.record(source)
9 print ('Done!')
C:\Users\user\Anaconda3\lib\site-packages\speech_recognition\__init__.py in
__enter__(self)
201 try:
202 # attempt to read the file as WAV
--> 203 self.audio_reader =
wave.open(self.filename_or_fileobject, "rb")
204 self.little_endian = True # RIFF WAV is a little-endian
format (most ``audioop`` operations assume that the frames are stored in
little-endian form)
205 except (wave.Error, EOFError):
C:\Users\user\Anaconda3\lib\wave.py in open(f, mode)
497 mode = 'rb'
498 if mode in ('r', 'rb'):
--> 499 return Wave_read(f)
500 elif mode in ('w', 'wb'):
501 return Wave_write(f)
C:\Users\user\Anaconda3\lib\wave.py in __init__(self, f)
157 self._i_opened_the_file = None
158 if isinstance(f, str):
--> 159 f = builtins.open(f, 'rb')
160 self._i_opened_the_file = f
161 # else, assume it is an open file object already
FileNotFoundError: [Errno 2] No such file or directory: 'Wel.wav'
Now when i try to give it with directory location,
i have changed the audio command as
audio = 'C:\\Users\\user\\Desktop\\Wel.wav'
It is throwing the below error :
Error Traceback (most recent call last)
C:\Users\user\Anaconda3\lib\site-packages\speech_recognition\__init__.py in
__enter__(self)
202 # attempt to read the file as WAV
--> 203 self.audio_reader =
wave.open(self.filename_or_fileobject, "rb")
204 self.little_endian = True # RIFF WAV is a little-endian
format (most ``audioop`` operations assume that the frames are stored in
little-endian form)
C:\Users\user\Anaconda3\lib\wave.py in open(f, mode)
498 if mode in ('r', 'rb'):
--> 499 return Wave_read(f)
500 elif mode in ('w', 'wb'):
C:\Users\user\Anaconda3\lib\wave.py in __init__(self, f)
162 try:
--> 163 self.initfp(f)
164 except:
C:\Users\user\Anaconda3\lib\wave.py in initfp(self, file)
129 if self._file.getname() != b'RIFF':
--> 130 raise Error('file does not start with RIFF id')
131 if self._file.read(4) != b'WAVE':
Error: file does not start with RIFF id
During handling of the above exception, another exception occurred:
Error Traceback (most recent call last)
C:\Users\user\Anaconda3\lib\site-packages\speech_recognition\__init__.py in
__enter__(self)
207 # attempt to read the file as AIFF
--> 208 self.audio_reader =
aifc.open(self.filename_or_fileobject, "rb")
209 self.little_endian = False # AIFF is a big-endian
format
C:\Users\user\Anaconda3\lib\aifc.py in open(f, mode)
889 if mode in ('r', 'rb'):
--> 890 return Aifc_read(f)
891 elif mode in ('w', 'wb'):
C:\Users\user\Anaconda3\lib\aifc.py in __init__(self, f)
339 # else, assume it is an open file object already
--> 340 self.initfp(f)
341
C:\Users\user\Anaconda3\lib\aifc.py in initfp(self, file)
304 if chunk.getname() != b'FORM':
--> 305 raise Error('file does not start with FORM id')
306 formdata = chunk.read(4)
Error: file does not start with FORM id
During handling of the above exception, another exception occurred:
EOFError Traceback (most recent call last)
C:\Users\user\Anaconda3\lib\site-packages\speech_recognition\__init__.py in
__enter__(self)
233 try:
--> 234 self.audio_reader = aifc.open(aiff_file, "rb")
235 except (aifc.Error, EOFError):
C:\Users\user\Anaconda3\lib\aifc.py in open(f, mode)
889 if mode in ('r', 'rb'):
--> 890 return Aifc_read(f)
891 elif mode in ('w', 'wb'):
C:\Users\user\Anaconda3\lib\aifc.py in __init__(self, f)
339 # else, assume it is an open file object already
--> 340 self.initfp(f)
341
C:\Users\user\Anaconda3\lib\aifc.py in initfp(self, file)
302 self._file = file
--> 303 chunk = Chunk(file)
304 if chunk.getname() != b'FORM':
C:\Users\user\Anaconda3\lib\chunk.py in __init__(self, file, align,
bigendian, inclheader)
62 if len(self.chunkname) < 4:
---> 63 raise EOFError
64 try:
EOFError:
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-29-5bee547ee15e> in <module>()
5 audio = 'C:\\Users\\user\\Desktop\\Wel.wav'
6
----> 7 with sr.AudioFile(audio) as source:
8 audio = r.record(source)
9 print ('Done!')
C:\Users\user\Anaconda3\lib\site-packages\speech_recognition\__init__.py
in __enter__(self)
234 self.audio_reader = aifc.open(aiff_file, "rb")
235 except (aifc.Error, EOFError):
--> 236 raise ValueError("Audio file could not be read
as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in
another format")
237 self.little_endian = False # AIFF is a big-endian
format
238 assert 1 <= self.audio_reader.getnchannels() <= 2, "Audio must
be mono or stereo"
ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native
FLAC; check if file is corrupted or in another format
Could anyone please help me regarding this .
I am facing the following error statement
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/5pido2dr.h5'
when trying to run keras-vis. The code block causing the error :
layer_idx = utils.find_layer_idx(model, 'dense_2') #after naming the layers
model.layers[layer_idx].activation = activations.softmax
model = utils.apply_modifications(model)
for class_idx in np.arange(10):
indices = np.where(y_train[:, class_idx] == 1.)[0]
idx = indices[0]
grads = visualize_saliency(model, layer_idx, filter_indices=class_idx,
seed_input=X_train[idx],
backprop_modifier='guided')
f, ax = plt.subplots(1, 2)
ax[0].imshow(X_train[idx][..., 0])
ax[1].imshow(grads, cmap='jet')
savename = "layer_activations" + str(class_idx) + ".png"
f.savefig(savename)
and the complete error output :
OSError Traceback (most recent call last)
c:\python36\lib\site-packages\vis\utils\utils.py in apply_modifications(model)
122 try:
--> 123 model.save(model_path)
124 return load_model(model_path)
c:\python36\lib\site-packages\keras\engine\network.py in save(self, filepath, overwrite, include_optimizer)
1084 from ..models import save_model
-> 1085 save_model(self, filepath, overwrite, include_optimizer)
1086
c:\python36\lib\site-packages\keras\engine\saving.py in save_model(model, filepath, overwrite, include_optimizer)
104
--> 105 f = h5py.File(filepath, mode='w')
106 opened_new_file = True
c:\python36\lib\site-packages\h5py\_hl\files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, **kwds)
311 fapl = make_fapl(driver, libver, **kwds)
--> 312 fid = make_fid(name, mode, userblock_size, fapl, swmr=swmr)
313
c:\python36\lib\site-packages\h5py\_hl\files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
147 elif mode == 'w':
--> 148 fid = h5f.create(name, h5f.ACC_TRUNC, fapl=fapl, fcpl=fcpl)
149 elif mode == 'a':
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\_objects.pyx in h5py._objects.with_phil.wrapper()
h5py\h5f.pyx in h5py.h5f.create()
OSError: Unable to create file (unable to open file: name = '/tmp/5pido2dr.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 302)
During handling of the above exception, another exception occurred:
FileNotFoundError Traceback (most recent call last)
<ipython-input-20-df7d3b5036c3> in <module>()
1 layer_idx = utils.find_layer_idx(model, 'dense_2') #after naming the layers
2 model.layers[layer_idx].activation = activations.softmax
----> 3 model = utils.apply_modifications(model)
4
5 for class_idx in np.arange(10):
c:\python36\lib\site-packages\vis\utils\utils.py in apply_modifications(model)
** 124 return load_model(model_path)
125 finally:
--> 126 os.remove(model_path)
127
128
FileNotFoundError: [WinError 3] The system cannot find the path specified: '/tmp/5pido2dr.h5'
There is an OS error preceding which appears to be the primary cause. I am not sure why this error arises. The .h5 filename keeps changing. With due research, I have suggestions that this could be a environmental variable issue and requires reinstall.
But am not sure the right method for debug. I am using WIN 10, with python 3.6.5, and jupyter 4.4.0