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
Related
I am trying to run a preprocessing pipeline using nipype and I get the following error message:
Traceback (most recent call last):
File "preprocscript.py", line 211, in <module>
preproc.run('MultiProc', plugin_args={'n_procs': 8})
File "/sw/anaconda/3/lib/python3.6/site-packages/nipype/pipeline/engine/workflows.py", line 579, in run
runner = plugin_mod(plugin_args=plugin_args)
File "/sw/anaconda/3/lib/python3.6/site-packages/nipype/pipeline/plugins/multiproc.py", line 162, in __init__
initargs=(self._cwd,)
File "/sw/anaconda/3/lib/python3.6/multiprocessing/pool.py", line 175, in __init__
self._repopulate_pool()
File "/sw/anaconda/3/lib/python3.6/multiprocessing/pool.py", line 236, in _repopulate_pool
self._wrap_exception)
File "/sw/anaconda/3/lib/python3.6/multiprocessing/pool.py", line 250, in _repopulate_pool_static
wrap_exception)
File "/sw/anaconda/3/lib/python3.6/multiprocessing/process.py", line 73, in __init__
assert group is None, 'group argument must be None for now'
AssertionError: group argument must be None for now
and I am not sure what exactly might be wrong in my code that leads to this or if this is an issue with my software.
I am on a linux system and use python 3.6.
The module you are using has a ProcessPoolExecuter being used in it. In Python 3.7 they added some additional arguments to that class, namely initargs which is what is being called in nipype multiprocess module you are using. Unfortunately it is not backwards compatible to 3.6 and they did not write in another way to use that module.
Your options are to upgrade or not use the multiprocessing portion of nipype.
So on my game I'm making, I'm trying to load the data files needed for the game, and when I load the file with pickle (The file has been loaded, I've double-checked that.) I get this error:
Traceback (most recent call last):
File "/Users/user/Downloads/Deeper-master/Deeper.py", line 257, in <module>
tutorialData = pickle.load(tutorialFile)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1384, in load
return Unpickler(file).load()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1075, in load_inst
klass = self.find_class(module, name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pickle.py", line 1130, in find_class
__import__(module)
ImportError: No module named __main__
I saw a question like this on Stack Overflow, but it's a little different than my situation, so sorry if this is a duplicate, I'm just trying to figure it out.
You can find my code here. The main script is Deeper.py, just to save time.
If you notice in your repo, you have a Deeper.pyc and Deeper.py. If I run Deeper.py, it raises the same exception as yours. If I run Deeper.pyc, it raises another exception:
Traceback (most recent call last):
File "Deeper.py", line 7, in <module>
ToolbarTile = pygame.image.load("ToolbarTile.png")
pygame.error: Couldn't open Toolbar Tile.png
So, the code (bytecode, some previous version) references ToolbarTile.png, but the exception is about Toolbar Tile.png (with a space). So I changed the file name to account for that.
Now it raises:
Traceback (most recent call last):
File "Deeper.py", line 766, in <module>
else:
File "Deeper.py", line 394, in __init__
def displayCraft(self):
pygame.error: Couldn't open options.png
There's an Options.png in your files, but it looks for options.png (lower case) (even your new code in Deeper.py looks for that). So I changed that.
Now it works, albeit with Deeper.pyc so that must be why you thought:
(The file has been loaded, I've double-checked that.)
Maybe delete the Deeper.pyc and do a git-bisect to see when the bug was introduced (ps: check your toolbar.dat, does it seem okay to you? Also check the way you're using pickle.load. Maybe you should use rb instead of r?)
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.
I am getting the following error when trying to export a pandas DataFrame to csv.
Traceback (most recent call last):
File "C:/Users/riley/PycharmProjects/EarlyPaidLoanReport/EarlyPaidOff.py", line 91, in <module>
LastTransactionDate.to_csv(LastTransactionDate, 'example.csv')
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\core\frame.py", line 1344, in to_csv
formatter.save()
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\formats\format.py", line 1526, in save
compression=self.compression)
File "C:\Users\riley\Anaconda3\lib\site-packages\pandas\io\common.py", line 424, in _get_handle
f = open(path, mode, errors='replace')
TypeError: invalid file: AutoNumber LoanAgreementID \
I'm not sure why I am getting this error. I've been writing to csv using pandas many times in the past. Could someone please help to fix this error?
LastTransactionDate.to_csv(LastTransactionDate, 'example.csv')
Your syntax is wrong. Unless I am missing something, just do this:
LastTransactionDate.to_csv('example.csv')
I am trying to load a resource which is present in my project using pkg_resources but it just throws me an exception saying that it quote "Can't perform this operation for loaders without 'get_data()'". I am not sure if I am doing something wrong here, or if pkg_resources is somehow broken on python 3.3. I am using python 3.3.3 to be exact. Here is the code I am trying to execute
>>> import pkg_resources
>>> data = pkg_resources.resource_stream('configgenerator', 'schema_rules.yml')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/users/frank/workspace/configgenerator/env/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg/pkg_resources.py", line 931, in resource_stream
self, resource_name
File "/home/users/frank/workspace/configgenerator/env/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg/pkg_resources.py", line 1207, in get_resource_stream
return StringIO(self.get_resource_string(manager, resource_name))
File "/home/users/frank/workspace/configgenerator/env/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg/pkg_resources.py", line 1210, in get_resource_string
return self._get(self._fn(self.module_path, resource_name))
File "/home/users/frank/workspace/configgenerator/env/lib/python3.3/site-packages/distribute-0.6.31-py3.3.egg/pkg_resources.py", line 1289, in _get
"Can't perform this operation for loaders without 'get_data()'"
NotImplementedError: Can't perform this operation for loaders without 'get_data()'
>>>
Does anyone has an idea on how to fix this?
This can happen for a number of reasons, but the the most common is that the package is not an importable module because there is no __init__.py.