3

I have installed docopt by typing pip3 install docopt and now it is well installed: You can see it on the list

umr5558-c02gl0y6drjm:Concatenate etudiant$ pip3 list
Package         Version
--------------- -------
biopython       1.71   
buildozer       0.34   
cycler          0.10.0 
docopt          0.6.2  
kiwisolver      1.0.1  
matplotlib      2.2.2  
nose            1.3.7  
numpy           1.14.2 
pexpect         4.5.0  
pip             10.0.0 
ptyprocess      0.5.2  
pyparsing       2.2.0  
python-dateutil 2.7.2  
pytz            2018.4 
scipy           1.0.1  
setuptools      39.0.1 
sh              1.12.14
six             1.11.0 
virtualenv      15.2.0 
wheel           0.30.0 

But when I try to import docoport from docopt on python3 it raises:

ModuleNotFoundError: No module named 'docopt'

Does someone have an idea?

Here is the path:

umr5558-c02gl0y6drjm:Concatenate etudiant$ pip3.6 install docopt
Requirement already satisfied: docopt in /usr/local/lib/python3.6/site-packages (0.6.2)

Here is the import section:

from Bio import codonalign 
from Bio.Align import MultipleSeqAlignment 
from Bio.SeqRecord import SeqRecord 
from Bio.Alphabet import IUPAC 
from Bio.Seq import Seq from Bio import AlignIO 
from Bio import pairwise2 
from Bio.codonalign.codonseq import _get_codon_list, CodonSeq, cal_dn_ds 
import scipy 
from Bio.Align.Applications import MuscleCommandline 
from Bio.Align import MultipleSeqAlignment 
from scipy.linalg import expm 
from Bio import SeqIO 
import sys 
import numpy as np 
from docopt import docopt

Thanks

Gwendal Grelier
  • 526
  • 1
  • 7
  • 21
Grendel
  • 555
  • 1
  • 4
  • 11
  • Are you sure that you have only one version of python installed ? – Gwendal Grelier Apr 17 '18 at 14:07
  • At least 2: Python 2.7.10 and Python 3.6.4 But is it a problem since I run Python3? – Grendel Apr 17 '18 at 14:19
  • I don't see another possible reason... Howard do y ou start your script ? with a command line ? By clicking on the .py file ? Which system do you work on ? Macos, win, Unix ? – Gwendal Grelier Apr 18 '18 at 06:08
  • I have a script with one function which I call by giving some arguments on the commande line, I already use some modules such as Bio, sys etc and they work well. I'm on MacBookPro and yes it is a .py file. Here is an exemple of the command line I use to run my script: python3 divergence.py concatenate_0035_fna_renamed.fst concatenate_0042_fna_renamed.fst concatenate_0035_faa_renamed.fst concatenate_0042_faa_renamed.fst dn_ds.out ML – Grendel Apr 18 '18 at 07:47
  • Can you add the part of the script where you import this module ? You should have something like this `from docopt import docopt` according to the doc. – Gwendal Grelier Apr 18 '18 at 11:47
  • here are my first lines: ` `from Bio import codonalign from Bio.Align import MultipleSeqAlignment from Bio.SeqRecord import SeqRecord from Bio.Alphabet import IUPAC from Bio.Seq import Seq from Bio import AlignIO from Bio import pairwise2 from Bio.codonalign.codonseq import _get_codon_list, CodonSeq, cal_dn_ds import scipy from Bio.Align.Applications import MuscleCommandline from Bio.Align import MultipleSeqAlignment from scipy.linalg import expm from Bio import SeqIO import sys import numpy as np from docopt import docopt` – Grendel Apr 18 '18 at 12:46
  • So, yes I used : `from docopt import docopt` – Grendel Apr 18 '18 at 12:47
  • Can you add the part where you call this library so I can try to reproduce you error ? – Gwendal Grelier Apr 18 '18 at 14:48
  • It is just at the beginning, let's say I have a file.py : I juste write : from docopt import docopt , and when I execute : python3 file.py it raises: ModuleNotFoundError: No module named 'docopt' , the same if I try directly on python3 – Grendel Apr 18 '18 at 15:34
  • I can't reproduce this error, everything works fine for me... Sorry =( – Gwendal Grelier Apr 18 '18 at 15:40
  • Finally I found my mistake, I had to change my pythonpath. – Grendel Apr 19 '18 at 08:49

2 Answers2

2

Hello Try it

sudo apt install python3-docopt
1

I had a similar problem and this is how I solved it:
I also had installed docopt via pip install docopt, and I have both python 2 and 3 in my mac.

The problem is that docopt is installed for python 3, but when running the .py file in terminal, it ran in python 2 by default.
Just add #!/usr/bin/env python3 to the very beginning of your .py file, and it should fix your issue.

Hippolippo
  • 803
  • 1
  • 5
  • 28
Kristin
  • 19
  • 2