I am trying to run align_epi_anat.py and encountering the following error. I tried to look it up in the actual Python script, but haven’t been able to figure out what it’s getting at (My optional arguments seem okay to me. I’m not sure what “trailers” would mean.) Any guidance would be hugely appreciated. Thanks.
The error:
File “/Users/…/abin/align_epi_anat.py”, line 1170
print(‘** ERROR: seem to have trailers, but cannot find them!’)
The shell script
align_epi_anat.py -anat ANAT.bc.ns+orig
-epi EPIREF4ANAT.ns.nii
-epi_base 0 -anat2epi -anat_has_skull no
-deoblique on
-epi_strip None -partial_coverage
-giant_move
-master_anat SOURCE -overwrite
The offending line in the Python script:
def get_user_opts(self):
self.valid_opts.check_special_opts(sys.argv) #ZSS March 2014
self.user_opts = read_options(sys.argv, self.valid_opts)
if self.user_opts == None: return 1 #bad
# no options: apply -help
if ( len(self.user_opts.olist) == 0 or
len(sys.argv) <= 1 ) :
ps.self_help()
ps.ciao(0) # terminate
if self.user_opts.trailers:
opt = self.user_opts.find_opt(‘trailers’)
if not opt:
print “** ERROR: seem to have trailers, but cannot find them!”
Thanks for your response. The shell script doesn’t show up the same when I c/p it into the forum; originally all the backslashes were aligned. However, I tried it with only one space after arguments, no space, and all arguments on same line. Still same error.
Still seems like a parsing issue from the terminal. Try reducing the problem to the minimum entry to test this out. Use just the -anat, -epi and -epi_base options or even just one of them. The script should exit with a message telling you to put the other non-optional options.
Thanks for the suggestion. Unfortunately, even when I just run the following, extremely basic script, the error persists: align_epi_anat.py -anat FT_anat+orig -epi FT_epi_r1+orig -epi_base 0 (even an incomplete script like “align_epi_anat.py -anat FT_anat+orig” or even just “align_epi_anat.py” by itself results in the same error).
The error again, for reference: File “/Users/…/abin/align_epi_anat.py”, line 1170
print “** ERROR: seem to have trailers, but cannot find them!”
^
SyntaxError: Missing parentheses in call to ‘print’
…I also ran file_tool as Paul suggested, and it seemed just fine (“03_testParsing.sh has 0 bad characters / 03_testParsing.sh file type: UNIX”)
Is it possible that something with my Python setup could be messing this up?
Going to jump in here - I feel like I see this error when I forget to use python 2.7 - specifically the missing parentheses portion. I have to activate my anaconda python 2.7 environment before I call AFNI scripts. There may be an easier alternative though, I’m not sure.
In regards to the comment from dowdlelt (thank you!), I tried running “deactivate py36” and “activate py27”, which produced a new error, referencing the same area of the align_epi_anat.py script (line 1170): “SyntaxError: Non-ASCII character ‘\xe2’ in file /Users/robertbacker/abin/align_epi_anat.py on line 1170, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details”. I’m not great with python, so hopefully I did the right thing.
In reply to Rick:
[left]1. My sincere apologies for complicating things! To clarify: the error was in fact: print “** ERROR: seem to have trailers, but cannot find them!”. (The parentheses were in my first post because I was trying to edit an alternative copy of the align_epi_anat.py in an attempt to troubleshoot the code. I dug around and saw that some python versions call for syntax with parentheses. I must have posted the new error by accident. I have not modified the original .py script, nor do I want to! The corrected error in this post stems from the original error from the original .py script.)
2. I wish I knew why I’m seeing it! I even get the error just trying to run something really basic like align_epi_anat.py -anat FT_anat+orig -epi FT_epi_r1+orig -epi_base 0. This wasn’t the case before.[/left]
Is your AFNI version current? I would be positive that
the script is unchanged. That Non-ASCII error suggests
that the script is still edited, and in particular, in a non-Unix
(non plain text) format.
I just recently updated AFNI. To be sure there were not issues from my own tinkering, I updated align_epi_anat.py again, however the error remains. Perhaps there’s some unique issue with my Python that I’m just not able to foresee?
I opted to uninstall all Python 3 things by running—afni_system_check.py -check_all > out.afni_system_check.txt—to check where all the Py3 files were installed and deleting them. Now everything works fine. Thanks for the help everyone.
1 Like
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.