I'm trying to use statsmodels.tsa.x13 with my Python 3.6 (anaconda\spider). I`ve already installed x13as and write this code:
X13PATH= os.chdir("C:\\x13\WinX13\\x13as")
x13results = x13_arima_analysis(endog = mb["G"], x12path=X13PATH, outlier=True,print_stdout=True)
where mb["G"] is pandas.core.series.Series. So, the result is following:
C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py:460: IOWarning: Failed to delete resource C:\Users\SERGEY~1\AppData\Local\Temp\tmp2iwvb0uo.spc
IOWarning)
C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py:463: IOWarning: Failed to delete resource C:\Users\SERGEY~1\AppData\Local\Temp\tmp_h3vwxc9
IOWarning)
Traceback (most recent call last):
File "<ipython-input-3-8e98768a4534>", line 2, in <module>
x13results = x13_arima_analysis(endog = mb["G"], x12path=X13PATH, outlier=True,print_stdout=True)
File "C:\Anaconda\lib\site-packages\statsmodels\tsa\x13.py", line 434, in x13_arima_analysis
ftempin.write(spec)
File "C:\Anaconda\lib\tempfile.py", line 483, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
What's the problem? I will be grateful for any help.
You need to pass as a string. Change
X13PATH= os.chdir("C:\\x13\WinX13\\x13as")
to
X13PATH= "C:\\x13\WinX13\\x13as"
From the statsmodels docs: "x12path (str or None) – The path to x12 or x13 binary. If None, the program will attempt to find x13as or x12a on the PATH or by looking at X13PATH or X12PATH depending on the value of prefer_x13."
Related
I am really new with ontologies especially with owlready2. I loaded an Ontology the basic example Pizza and imported I think successfully on python (I checked whether I can see the classes which I can so..)
Than I used the following code to search one class specifically with the method search():
from owlready2 import *
onto_path.append(r"C:/Users/AyselenKuru/Desktop/owl_docs/owlpizza.owl")
onto=get_ontology(r"C:/Users/AyselenKuru/Desktop/owl_docs/owlpizza.owl")
onto.load()
am= onto.search_one(is_a= onto.American)
for x in onto.classes():
print(x)
I want to know how can I search/get one specific Class and an Attribute and I get the following error message:
Traceback (most recent call last):
File "c:\Users\AyselenKuru\Desktop\pizza_ex1.py", line 6, in <module>
am= onto.search_one(is_a = onto.American)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AyselenKuru\AppData\Local\Programs\Python\Python311\Lib\site-packages\owlready2\namespace.py", line 395, in search_one
def search_one(self, **kargs): return self.search(**kargs).first()
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AyselenKuru\AppData\Local\Programs\Python\Python311\Lib\site-packages\owlready2\namespace.py", line 364, in search
else: v2 = v.storid
^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'storid'
Problem solved itself, the example owl File had errors with IRI that caused a Problem with the search
I have a small chunk of code which not being a python guru I am not sure what it is really 'doing', but it fails under python3:
if indSoundsToPlay:
indSoundsToPlay = list(indSoundsToPlay)
indSoundsToPlay.sort()
soundsToPlay = list(zip(*indSoundsToPlay)[1]) <-- fails
soundsToPlay.reverse() # since played from back to front
self.playSounds(soundsToPlay)
This worked fine in Python2, but upon converting it did not like the list zip line at all. So I converted that line to:
soundsToPlay = list(zip(*indSoundsToPlay))
It was okay with that, I am not sure what the list zip * is really doing in python. Though the error subsided but now I realized that I painted myself into either a) another error or b) a new error just near the same code. The slice of code that now breaks is :
What error I get now is on the function call to playSounds:
def playSounds(self, sounds):
"""Play one or more of a set of sounds; played in order from last to first.
"""
if not sounds:
return
soundFunc = sounds.pop(-1)
soundFunc()
if sounds:
self._soundTimer.start(_SoundInterval, self.playSounds, sounds)
KeyVar('tcc', 'AxisCmdState') <bound method AxisStatusWdg.setAxisCmdState of <TUI.TCC.StatusWdg.AxisStatus.AxisStatusWdg object .!toplevel46.!statuswdg.!axisstatuswdg>>(*(['Drifting', 'Drifting', 'Drifting'],), **{'isCurrent': True, 'keyVar': KeyVar('tcc', 'AxisCmdState', 3, str)}) failed: 'tuple' object is not callable
Traceback (most recent call last):
File "/Users/st/TUI3/RO/AddCallback.py", line 77, in safeCall2
return func(*args, **kwargs)
File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 300, in setAxisCmdState
self.playSounds(soundsToPlay)
File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 359, in playSounds
soundFunc()
TypeError: 'tuple' object is not callable
KeyVar('tcc', 'AxisCmdState') <bound method AxisStatusWdg.setAxisCmdState of <TUI.TCC.StatusWdg.AxisStatus.AxisStatusWdg object .!toplevel46.!statuswdg.!axisstatuswdg>>(*(['Tracking', 'Tracking', 'Tracking'],), **{'isCurrent': True, 'keyVar': KeyVar('tcc', 'AxisCmdState', 3, str)}) failed: 'tuple' object is not callable
Traceback (most recent call last):
File "/Users/st/TUI3/RO/AddCallback.py", line 77, in safeCall2
return func(*args, **kwargs)
File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 300, in setAxisCmdState
self.playSounds(soundsToPlay)
File "/Users/st/TUI3/TUI/TCC/StatusWdg/AxisStatus.py", line 359, in playSounds
soundFunc()
TypeError: 'tuple' object is not callable
I don't know if it's what I did to indSoundsToPlay with the changing of that list(zip command or if it is a separate error in general. So not really sure where to start with this one besides learning what list(zip(* means in python.
I am running under Python 3.7 on Linux Ubuntu 18.04 under Eclipse 4.8 and Pydev.
The declaration:
args:Dict[str: Optional[Any]] = {}
is in a module that is imported from my testing code. and it is flagged with the following error message from typing.py:
TypeError: Parameters to generic types must be types. Got slice(<class 'str'>, typing.Union[typing.Any, NoneType], None). The stack trace follows: Finding files... done. Importing test modules ... Traceback (most recent call last): File "/Data/WiseOldBird/Eclipse/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/_pydev_runfiles/pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname) File "/Data/WiseOldBird/Workspaces/WikimediaAccess/WikimediaLoader/Tests/wiseoldbird/loaders/TestWikimediaLoader.py", line 10, in <module>
from wiseoldbird.application_controller import main File "/Data/WiseOldBird/Workspaces/WikimediaAccess/WikimediaLoader/src/wiseoldbird/application_controller.py", line 36, in <module>
args:Dict[str: Optional[Any]] = {} File "/usr/local/lib/python3.7/typing.py", line 251, in inner
return func(*args, **kwds) File "/usr/local/lib/python3.7/typing.py", line 626, in __getitem__
params = tuple(_type_check(p, msg) for p in params) File "/usr/local/lib/python3.7/typing.py", line 626, in <genexpr>
params = tuple(_type_check(p, msg) for p in params) File "/usr/local/lib/python3.7/typing.py", line 139, in _type_check
raise TypeError(f"{msg} Got {arg!r:.100}.") TypeError: Parameters
This prevents my testing module from being imported.
What am I doing wrong?
The proper syntax for a dict's type is
Dict[str, Optional[Any]]
When you write [a: b], Python interprets this as a slice, i.e. the thing that makes taking parts of arrays work, like a[1:10]. You can see this in the error message: Got slice(<class 'str'>, typing.Union[typing.Any, NoneType], None).
I'm using python 2.7.12. Running pd.__version__ returns u'0.19.0'.
I'm using a module called dalmatian. For one of the functions, once I run verbatim what is provided in the documentation, I get the error:
wm.update_participant_set('all_participants', participant_df.index)
TypeError: unicode argument expected, got 'str'
I have an inkling suspicion that this might be due to the version of pandas or python that I'm using. Running participant_df.index returns:
Index([u'100_2', u'101_3', u'102_2', u'103_3', u'104_2', u'105_2', u'106_4',
u'107_4', u'108_4', u'109_1',
...
u'91_2', u'92_3', u'93_2', u'94_4', u'95_4', u'96_3', u'97_2', u'98_3',
u'99_1', u'9_1'],
dtype='object', name=u'participant_id', length=523)`
I've also tried submitting this as .astype(unicode) and as .index.values. I suppose I don't really know how to troubleshoot this further. Any thoughts?
EDIT TO INCLUDE TRACEBACK
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "/gpfs/fs1/home/jrouhana/jrouhana/lib/python2.7/site-packages/dalmatian/wmanager.py", line 1045, in update_participant_set
self.update_entity_set('participant', participant_set_id, participant_ids)
File "/gpfs/fs1/home/jrouhana/jrouhana/lib/python2.7/site-packages/dalmatian/wmanager.py", line 1030, in update_entity_set
self.upload_entities('{}_set'.format(etype), set_df, index=False)
File "/gpfs/fs1/home/jrouhana/jrouhana/lib/python2.7/site-packages/dalmatian/wmanager.py", line 164, in upload_entities
df.to_csv(buf, sep='\t', index=index)
File "/modules/EasyBuild/software/pandas/0.19.0-foss-2016b-Python-2.7.12/lib/python2.7/site-packages/pandas-0.19.0-py2.7-linux-x86_64.egg/pandas/core/frame.py", line 1381, in to_csv
formatter.save()
File "/modules/EasyBuild/software/pandas/0.19.0-foss-2016b-Python-2.7.12/lib/python2.7/site-packages/pandas-0.19.0-py2.7-linux-x86_64.egg/pandas/formats/format.py", line 1475, in save
self._save()
File "/modules/EasyBuild/software/pandas/0.19.0-foss-2016b-Python-2.7.12/lib/python2.7/site-packages/pandas-0.19.0-py2.7-linux-x86_64.egg/pandas/formats/format.py", line 1562, in _save
self._save_header()
File "/modules/EasyBuild/software/pandas/0.19.0-foss-2016b-Python-2.7.12/lib/python2.7/site-packages/pandas-0.19.0-py2.7-linux-x86_64.egg/pandas/formats/format.py", line 1530, in _save_header
writer.writerow(encoded_labels)
TypeError: unicode argument expected, got 'str'
I facced same error, the code was written in python 3, but i was running it with python 2.
so swiching to python 3 worked for me.
Add the following at the beginning of the file:
from __future__ import unicode_literals
I am trying to run the program genipe to do some genome-wide survival analysis. I have installed genipe and all the relevant directories. However, when I go to run the program I get the error:
"TypeError: _ init _() got an unexpected keyword argument 'normalize'"
I haven't edited any of the genipe scripts and I have run genipe with no issues on a different server so I am not sure what is going wrong! Any help would be greatly appreciated.
Many thanks,
Caragh
Edit:
I am using python version 3.6.1
Traceback as follows:
Traceback (most recent call last):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 965, in process_impute2_site
use_ml=site_info.use_ml,
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 1048, in fit_cox
cf = CoxPHFitter(alpha=0.95, tie_method="Efron", normalize=False)
TypeError: __init__() got an unexpected keyword argument 'normalize'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 811, in compute_statistics
for result in pool.map(process_impute2_site, sites_to_process):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 608, in get
raise self._value
TypeError: __init__() got an unexpected keyword argument 'normalize'
[2017-05-31 14:18:53 ERROR] __init__() got an unexpected keyword argument 'normalize'
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
return list(map(*args))
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 965, in process_impute2_site
use_ml=site_info.use_ml,
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 1048, in fit_cox
cf = CoxPHFitter(alpha=0.95, tie_method="Efron", normalize=False)
TypeError: __init__() got an unexpected keyword argument 'normalize'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/bin/imputed-stats", line 11, in <module>
sys.exit(main())
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 161, in main
options=args,
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/site-packages/genipe/tools/imputed_stats.py", line 811, in compute_statistics
for result in pool.map(process_impute2_site, sites_to_process):
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 260, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "/users/k1640238/miniconda/envs/genipe_pyvenv/lib/python3.6/multiprocessing/pool.py", line 608, in get
raise self._value
TypeError: __init__() got an unexpected keyword argument 'normalize'
Judging by the lifeline changelog this keyword argument has been removed from this particular function. Lifeline is a package which contains this particular function and is used by genipe.
You can either install previous version of lifeline by yourself and see if that will help or wait for updates in genipe library.
Looking at further errors from your comments, it seems like this is problematic code. You are trying to use dmatrices but it seems like it is not defined. Probably because mentioned try/catch block couldn't find statsmodel installed and therefore patsy wasn't imported either.
Try to install few more packages manually, starting with
statsmodel
patsy
and see if you will get any errors then...
See errata's answer above, I was using the wrong versions of some of the dependancies, but even with that the program was still giving me errors. However when I reverted to python 3.4, the program worked.