Amine-Namouchi / snpToolkit

GNU General Public License v3.0
4 stars 0 forks source link

ImportError: attempted relative import with no known parent package #1

Closed ffontani closed 3 years ago

ffontani commented 3 years ago

Hi @Amine-Namouchi!

Since I attended the Physalia course on Paleogenomics last November, snpToolkit worked fine on my Mac. Then I switched to Ubuntu 20.04, installed snpToolkit with 'pip', seemed to work fine, but every time I try to use --explore or --annotate command, I get stuck in the following error:

(myenv) user@Ubuntu:~/path-to-my-vcf.gz/$ snptoolkit explore -i mysample.vcf.gz 

Traceback (most recent call last):
  File "/home/user/anaconda3/bin/explore_snpToolkit.py", line 41, in <module>
    from annotate_snpToolkit import *
  File "/home/user/anaconda3/bin/annotate_snpToolkit.py", line 16, in <module>
    from .version import version 
ImportError: attempted relative import with no known parent package

OR

(myenv) user@Ubuntu:~/path-to-my-vcf.gz/$ snptoolkit annotate -i mysample.vcf.gz -g /path-to-my-reference/reference.gb -d 2 -q 20 -r 0.9`
Traceback (most recent call last):
  File "/home/user/anaconda3/envs/snpToolkit/bin/snptoolkit", line 53, in <module>
    from annotate_snpToolkit import parse_genbank_file
  File "/home/user/anaconda3/envs/snpToolkit/bin/annotate_snpToolkit.py", line 16, in <module>
    from .version import version 
ImportError: attempted relative import with no known parent package

I know it could be something really easy to solve, but I'm not able to figure out how to.

Best, Francesco

mftorres commented 3 years ago

I was having the same issue after installing the software via conda in Ubuntu 20.04. I fixed it by commenting out the line importing the .version library in the annotate_snpToolkit.py file. It works fine for me now.

The lines look like:

#from .version import version
__licence__ = 'GPLv3'
__author__ = 'Amine Namouchi'
__author_email__ = 'amine.namouchi@gmail.com'
__version__ = '2.2.8'

The issue is caused by a relative import (you can see an explanation here). I reckon you don't need the version while you do your analysis (and while the issue is resolved).

ffontani commented 3 years ago

I was having the same issue after installing the software via conda in Ubuntu 20.04. I fixed it by commenting out the line importing the .version library in the annotate_snpToolkit.py file. It works fine for me now.

The lines look like:

#from .version import version
__licence__ = 'GPLv3'
__author__ = 'Amine Namouchi'
__author_email__ = 'amine.namouchi@gmail.com'
__version__ = '2.2.8'

The issue is caused by a relative import (you can see an explanation here). I reckon you don't need the version while you do your analysis (and while the issue is resolved).

Thank you @mftorres, is working fine now!