Python error: ImportError: No module named decorator

Hello,

I’ve been trying to run Hail locally and have been getting this error when I try to import Hail:

Traceback (most recent call last):
File “”, line 1, in
File “/work-zfs/darking1/software/src/hail/python/hail/init.py”, line 1, in
from hail.context import HailContext
File “/work-zfs/darking1/software/src/hail/python/hail/context.py”, line 5, in
from hail.dataset import VariantDataset
File “/work-zfs/darking1/software/src/hail/python/hail/dataset.py”, line 3, in
from hail.java import *
File “/work-zfs/darking1/software/src/hail/python/hail/java.py”, line 2, in
from decorator import decorator
ImportError: No module named decorator

Thank you,

Rebecca

I didn’t realize that this package wasn’t included in some python distributions, so I’ll think about a longer-term solution. For now, use pip to install the package:

pip install decorator

or on a shared cluster with no root access:

pip install decorator --user

I ran into a similar issue when testing out the latest Hail version on the google cloud. I just tried to run the count script from Using Hail on the Google Cloud Platform with a small vds:

Traceback (most recent call last):
File “/tmp/4fb6177b-679b-459a-a5b0-d370f245de96/count_test.py”, line 1, in
from hail import *
File “/home/ec2-user/BuildAgent/work/c38e75e72b769a7c/python/hail/init.py”, line 1, in
File “/home/ec2-user/BuildAgent/work/c38e75e72b769a7c/python/hail/context.py”, line 5, in
File “/home/ec2-user/BuildAgent/work/c38e75e72b769a7c/python/hail/dataset.py”, line 3, in
File “/home/ec2-user/BuildAgent/work/c38e75e72b769a7c/python/hail/java.py”, line 2, in
ImportError: No module named decorator

How can I fix this for the google cloud?

Thanks,
Carolina

To install decorator on the google cloud, you can add the following initialization script when starting your cluster:
gs://hail-common/hail-init.sh.
If you start your cluster using the command line, simply add --initialization-actions gs://hail-common/hail-init.sh, if you’re using the webUI to start your cluster then add the script in the initialization actions field at the bottom.

Here is the content of the script:

gsutil cat gs://hail-common/hail-init.sh
#!/bin/bash

easy_install pip
pip install decorator

Cheers,
Laurent

2 Likes

Hi,

we’re trying to run Hail on Google Cloud with dataproc image version 1.1.49 (and hence Spark 2.0.2) but getting the error “No module named decorator” at the very start. This happens even if we initialize the cluster with gs://hail-common/hail-init.sh. Have you observed this with 1.1.49, and can you recommend a workaround? Please see the error message and the script below.

Many thanks for your help in advance!

—error
Traceback (most recent call last):
File “/tmp/42c719bf-ecfa-44aa-bb23-f8dcfa68da2a/myhailtest.py”, line 2, in
from hail import *
File “/home/ec2-user/BuildAgent/work/4d93753832b3428a/python/hail/init.py”, line 1, in
File “/home/ec2-user/BuildAgent/work/4d93753832b3428a/python/hail/expr.py”, line 2, in
File “/home/ec2-user/BuildAgent/work/4d93753832b3428a/python/hail/java.py”, line 7, in
ImportError: No module named decorator

—script
from hail import *
from pprint import pprint

hc = HailContext()

vds = (
hc
.import_vcf(‘gs://annotationdb/ADMIN/test/sample.vcf’)
.split_multi()
.annotate_variants_db([
‘va.cadd.RawScore’,
‘va.cadd.PHRED’
])
)

How are you starting Python on the cluster? It must be a different Python executable than the one that knows where decorator was installed.