1

I am writing a job submission script for SLURM workload manager. First, I have loaded anaconda2/4.5.12 (including python 2.7) module. Then, I have created conda environment with Python3.7 version. I try to submit the script using "sbatsh" command, but I get this error:

Fatal Python error: initfsencoding: Unable to get the locale encoding
File "/cm/shared/apps/anaconda2/4.5.12/lib/python2.7/encodings/__init__.py", line 123
raise CodecRegistryError,\
                        ^
SyntaxError: invalid syntax
Current thread 0x00002aaaaaaffc00 (most recent call first):
/cm/local/apps/slurm/var/spool/job04287/slurm_script: line 19: 40032 
Aborted                 python3 taxo.TXT

This is my script file:

#!/bin/bash
#
#SBATCH --job-name=taxjob
#SBATCH --nodes=4

#SBATCH --tasks-per-node=3
#SBATCH --time=0-03:00:00
#SBATCH --partition=shortq 
#SBATCH --mem=24GB 
#SBATCH --output=/home/s.e/tax/Ftest-%j.out
#SBATCH --error=/home/s.e/tax/Ftest-%j.err
module load anaconda2/4.5.12
source activate py37
python3  taxo.TXT

2 Answers 2

2

After many tries, the solution was to add the instruction "unset PYTHONPATH" to my script file as follows:

....    
module load anaconda2/4.5.12
source activate py37
unset PYTHONPATH
python3  taxo.TXT
Sign up to request clarification or add additional context in comments.

Comments

0

The problem is that the "/cm/shared/apps/anaconda2/4.5.12/lib/python2.7/encodings/__init__.py" if a python2 file, like you can see at the path, but it is trying to be interpreted as a python3 file. You can either fix this conda problem and run it using python2.7 or edit the encodings/__init__.py file to make it python3-interpretable

To understand the problem you can try to run this line in python2 and python3 manually:

#Python3
>>> raise Exception,\
  File "<stdin>", line 1
    raise Exception,\
                   ^
SyntaxError: invalid syntax

but

#Python2.7
>>> raise Exception,\
...

Python3 analog of raise Exception,\ "str" is raise Exception("str"). So you can change the 123rd line of the file, but it's not a good idea, because other problems may occur, so it's better to fix something in configs/executing commands of anaconda

7 Comments

If you decide to edit the file, you have to replace lines 123 to 125 with raise CodecRegistryError('module "%s" (%s) failed to register' % (mod.__name__, mod.__file__))
Thank you for answering, I am not able to modify the file because only the administrator of the HPC can edit shared modules such as anaconda2/4.5.12
I can't use Python2.7 as well, because I am using some packages which are available only for python version > 3.x
Then, I guess, you have to switch to the encodings library for python3
How can I do it, please?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.