IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Calcul scientifique Python Discussion :

SyntaxError: unexpected EOF while parsing


Sujet :

Calcul scientifique Python

  1. #1
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut SyntaxError: unexpected EOF while parsing
    Bonjour à tous !

    Je viens solliciter votre aide pour me débloquer avec mon code python.

    mon problème est que je ne peux pas vérifier si celui-ci est correct car lors de

    l’exécution avec spyder, dès que je lance mon programme j'ai l'erreur SyntaxError: unexpected EOF while parsing

    qui apparait au niveau de :

    -def networks_project() : ligne 1

    - for line in lecture: : ligne 12

    -ligne 13 j'ai également l'erreur : NameError: name 'line' is not defined ce que je ne comprends pas car line est utilisé pour lire un fichier ligne par ligne

    - if(sequence>0): ligne 14

    -en fait, à chaque fois que je fais un for, if, ...
    -J'ai également l'impression qu'il ne lit pas mon fichier

    Cette erreur se retrouve tout au long de mon code mais j'ai beau avoir cherché pendant plusieurs jours, je ne vois pas ce qui est mal exécuter dans mon code.... Je crois que l'erreur principale serait dû à un manque de parenthèse.

    Je remercie d'avance toutes les personnes qui me consacreront de leur temps et qui m'aideront.

    Cordialement,

    Voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    # -*- coding: utf-8 -*-
     
    import os, sys
    import re
    import numpy as np 
    from Bio import pairwise2
    import networkx as nx
    import matplotlib.pyplot as plt
     
    def network_project():
        gene=[]     
        header=[]
        lecture=''
        i=0
        j=0
        file='exemple_sequence.txt'
        lecture=open(file,"r")      
        seq=''     
        for line in lecture:    
            sequence=len(re.findall(r"[>]",line))   
            if(sequence>0):     
                gene.append(seq)    
                seq=''
                sequence=0
                header.append(line[1:-1])  
                i=i+1
            else:
                seq=seq+line[:-1] 
        gene.append(seq)    
        lecture.close()   
     
        score=[]
        for i in range(len(gene)):
            for j in range((i+1),len(gene)):
                score.append(pairwise2.align.globalms(gene[i],gene[j], 3, -2, -1, -.5,score_only=True))
        liste=[]
        seuil=(np.mean(score)+0.05*np.std(score))  
        s=0
        edge_labels={}
        for i in range(len(gene)):
            for j in range((i+1),len(gene)):
                if(score[s]>seuil):
                    liste.append((header[i],header[j]))
                    edge_labels[(header[i],header[j])]=score[s]
                s=s+1
        G=nx.Graph()
        G.add_nodes_from(header)
        G.add_edges_from(liste)
        pos=nx.spring_layout(G)
        node_s=[]
        t=0
        for t in range(len(gene)):
            node_s.append(20*np.log(len(seq[t])))
        nx.draw_networkx_nodes(G,pos,node_color='green',label=True,alpha=1,node_size=node_s)
        Width=dict(edge_labels)
        for key,value in Width.items() :
            Width[key] = np.log10(value)/2
        nx.draw_networkx_edges(G,pos,width=Width.values(),style='solid',edge_color='red',alpha=1)
        nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_labels,font_size=2,alpha=0.5,font_color='black')
        nx.draw_networkx_labels(G,pos,font_size=3,font_color='blue')
     
        namefordoc=input('Nom du PDF sans .pdf ?\n')
        plt.savefig(namefordoc+'.pdf')
    et voici le fichier 'exemple_sequence.txt qui ne me semble pas être lu :

    >Horse gene mitochondrial du cytochrome b
    ATGACAAACATCCGGAAATCTCACCCACTAATTAAAATCATCAATCACTCTTTTATTGACCTACCAGCCC
    CCTCAAACATTTCATCATGATGAAACTTCGGCTCCCTCCTAGGAATCTGCCTAATCCTCCAAATCTTAAC
    AGGCCTATTCCTAGCCATACACTACACATCAGACACGACAACTGCCTTCTCATCCGTCACTCACATCTGC
    CGAGACGTTAACTACGGATGAATTATCCGCTACCTCCATGCCAACGGAGCATCAATATTTTTTATCTGCC
    TCTTCATTCACGTAGGACGCGGCCTCTACTACGGCTCTTACACATTCCTAGAGACATGAAACATTGGAAT
    CATCCTACTTTTCACAGTTATAGCTACAGCATTCATGGGCTATGTCCTACCATGAGGCCAAATATCCTTT
    TGAGGAGCAACAGTCATCACAAACCTCCTATCAGCAATTCCCTACATCGGTACTACCCTCGTCGAATGAA
    TCTGAGGTGGATTCTCAGTAGACAAAGCCACCCTTACCCGATTTTTTGCTTTCCACTTCATCCTACCCTT
    CATCATCACAGCCCTGGTAGTCGTACATTTACTATTTCTTCACGAAACAGGATCTAACAACCCCTCAGGG
    ATCCCATCCGATATGGACAAAATCCCATTCCACCCATATTATACAATTAAAGACATCCTAGGACTCCTCC
    TCCTGATCTTGCTCCTACTAACTCTAGTATTATTCTCCCCCGACCTCCTAGGAGACCCAGACAACTACAC
    CCCAGCTAACCCTCTCAGCACTCCCCCTCATATTAAACCAGAATGGTACTTCCTGTTTGCCTACGCCATC
    CTACGCTCCATTCCCAACAAACTAGGAGGCGTATTAGCCCTAATCCTCTCCATCCTGATCCTAGCACTCA
    TCCCCACCCTCCACATATCAAAACAACGAAGCATAATGTTCCGGCCTCTCAGCCAATGCGTATTCTGACT
    CTTAGTGGCAGACTTACTGACACTAACATGAATCGGCGGACAGCCAGTGGAACACCCATACGTAATTATC
    GGCCAACTGGCCTCAATCCTCTACTTCTCCCTAATTCTCATTTTTATACCACTCGCAAGCACCATCGAAA
    ACAATCTTCTAAAATGAAGA


    >Giraffe gene mitochondrial du cytochrome b
    ATGATCAACATCCGAAAGTCCCACCCACTAATAAAAATTGTAAATAACGCACTAATCGATCTACCAGCCC
    CATCAAATATCTCATCATGATGAAACTTCGGCTCCCTACTAGGCATCTGCCTCATTTTACAAATTCTAAC
    AGGCCTATTTCTAGCAATACACTACACACCTGACACAACAACAGCGTTCTCCTCTGTCACCCATATTTGC
    CGAGATGTTAACTACGGTTGAATCATCCGATATATACACGCAAATGGGGCATCCATATTCTTCATCTGCT
    TATTCATGCATGTAGGACGGGGCCTATACTACGGATCGTATACCTTCCTAGAAACATGAAACATTGGAGT
    AATCCTCCTATTCACAGTAATAGCCACAGCTTTTATAGAGTACGTCCTACCATGAGGACAAATATCATTT
    TGAGGAGCAACAGTCATTACTAATCTCCTATCAGCAATCCCATATATCGGCACAAATCTAGTCGAATGAA
    TCTGAGGGGGCTTCTCAGTAGATAAAGCAACCCTTACCCGATTCTTCGCCTTCCACTTCATTCTCCCATT
    CATCATTATAGCACTCACTATAGTCCACCTACTCTTTCTTCACGAAACAGGATCAAACAACCCAATAGGA
    ATTCCATCAGACATAGACAAAATCCCGTTCCACCCCTACTACACTATCAAAGATATCTTAGGGGCACTTC
    TATTAATTCTAGTCCTAATACTTCTAGTCCTATTTACACCCGACCTGCTCGGAGACCCAGATAACTACAC
    ACCAGCCAACCCACTCAATACTCCTCCCCATATTAAACCAGAATGATACTTTCTATTTGCATACGCAATC
    CTACGATCAATCCCCAACAAACTAGGAGGAGTCCTAGCCCTAGTTCTCTCCATCCTCATCCTCATCTTCA
    TACCCCTACTCCACACATCCAAACAACGAAGTATGATATTTCGACCATTCAGTCAATGCCTATTTTGAAT
    TCTAGTAGCGGACCTGCTAACACTCACATGAATTGGAGGACAGCCAGTTGAACACCCATTCATCATCATC
    GGACAACTAGCATCTATTATGTACTTTCTCATCATCCTAGTGTTAATACCAGTCACTAGTGCAATCCAAA
    ACAACCTTCTAAAATGAAGA


    >Goat gene mitochondrial du cytochrome b
    ATGACCAACATCCGAAAGACCCACCCATTAATAAAAATTGTAAACAACGCATTTATTGACCTCCCAACCC
    CATCAAACATCTCATCATGATGAAACTTTGGATCCCTCCTAGGAATTTGCCTAATCTTACAAATCCTGAC
    AGGCCTATTCCTAGCAATACACTATACATCCGACACAATAACAGCATTTTCCTCTGTAACTCACATTTGT
    CGAGATGTAAATTATGGCTGAATCATCCGATACATACACGCAAACGGAGCATCAATATTCTTTATCTGCC
    TATTCATACATATCGGACGAGGTCTATATTATGGATCATATACCTTTCTAGAAACATGAAACATTGGAGT
    AATCCTCCTGCTCGCAACAATGGCCACAGCATTCATAGGCTATGTTTTACCATGAGGACAAATATCATTT
    TGAGGGGCAACAGTCATCACTAATCTTCTTTCAGCAATCCCATATATTGGCACAAACCTAGTCGAATGAA
    TCTGAGGGGGGTTCTCAGTAGACAAAGCCACTCTCACCCGATTCTTCGCCTTCCACTTTATCCTCCCATT
    CATCATCACAGCCCTCGCCATAGTCCACCTGCTCTTCCTCCACGAAACAGGATCGAACAACCCCACAGGA
    ATTCCATCAGACACAGATAAAATCCCATTTCACCCTTACTACACCATTAAAGATATCTTAGGCGCCATGC
    TACTAATTCTTGTTCTAATATTACTAGTACTATTCACACCCGACCTACTCGGAGACCCAGACAACTATAT
    CCCAGCAAATCCACTCAATACACCCCCTCACATTAAACCTGAGTGGTATTTCCTATTTGCATACGCAATC
    CTACGATCAATCCCCAACAAACTAGGAGGAGTCCTAGCCCTAGTCCTCTCAATCCTAATCTTAGTACTTG
    TACCCTTCCTCCACACATCTAAACAACGAAGCATAATATTCCGCCCAATCAGCCAATGCATATTCTGAAT
    CCTGGTAGCAGATCTATTAACACTCACATGAATTGGAGGACAGCCAGTCGAACATCCCTACATTATTATT
    GGACAACTAGCATCTATTATATATTTCCTCATCATTCTAGTAATAATACCAGCAGCTAGCACCATTGGAA
    ACAACCTTCTAAAATGAAGA


    >Sheep gene mitochondrial du cytochrome b
    ATGACCAACATCCGAAAAACCCACCCACTAATAAAAATTGTAAACAACGCATTCATTGACCTCCCAGCTC
    CATCAAATATTTCATCATGATGAAACTTTGGCTCCCTCCTAGGCATTTGCTTAATTTTACAGATTCTAAC
    AGGCCTATTCCTAGCAATACACTATACACCCGACACAACAACAGCATTCTCCTCTGTAACCCACATTTGC
    CGAGACGTGAACTATGGCTGAATTATCCGATATATACACGCAAACGGGGCATCAATATTTTTTATCTGCC
    TATTTATGCATGTAGGACGAGGCCTATATTATGGATCATATACCTTCCTAGAAACATGAAACATCGGAGT
    AATCCTCCTATTTGCGACAATAGCCACAGCATTCATAGGCTATGTCTTACCATGAGGACAAATATCATTC
    TGAGGAGCAACAGTTATTACCAACCTCCTTTCAGCAATTCCATATATTGGCACAAACCTAGTCGAATGAA
    TCTGGGGAGGATTCTCAGTAGACAAAGCTACCCTCACCCGATTTTTCGCCTTTCACTTTATTTTCCCATT
    CATCATCGCAGCCCTCGCCATAGTTCACCTACTCTTCCTCCACGAAACAGGATCCAACAACCCCACAGGA
    ATTCCATCGGACACAGATAAAATTCCCTTCCACCCTTATTACACCATTAAAGACATCCTAGGCGCCATAC
    TACTAATCCTTGCCCTCATGCTACTAGTACTATTCACACCTGACTTACTCGGAGACCCAGATAACTATAC
    CCCAGCAAACCCACTCAACACACCCCCTCACATTAAACCTGAATGATATTTCCTATTTGCATACGCAATC
    CTACGATCAATTCCCAATAAACTAGGAGGAGTCTTAGCCCTAGTCCTCTCGATCCTAATCCTAGTACTCG
    TACCTTTCCTCCACACATCCAAACAATGAAGCATAATATTCCGACCAATTAGTCAATGTATATTCTGAAT
    CTTAGGAGCAGACCTACTAACACTCACATGAATTGGAGGACAGCCAGTCGAACACCCTTATATCGTCATT
    GGACAACTAGCATCTATTATATATTTCCTTATCATTCTAGTAGTAATACCAGTAGCTAGCACTATCGAAA
    ATAACCTCCTAAAATGAAGA


    >Hippopotamus gene mitochondrial du cytochrome b
    ATGACAAACATCCGAAAATCTCACCCCTTAATAAAAATTATCAACGATGCATTCGTTGACCTCCCAGCTC
    CATCAAACATCTCATCGTGATGAAACTTCGGCTCCCTACTTGGCGTCTGCCTAATCCTACAAATTCTAAC
    AGGCCTATTCCTGGCCATACACTACACACCAGATACACTCACCGCATTCTCATCGGTAACCCACATCTGC
    CGTGATGTAAACTACGGGTGAGTCATCCGCTACATACACGCAAACGGCGCATCCATCTTCTTCATCTGCC
    TCTTTACTCACGTAGGACGCGGCCTATACTATGGCTCCTACACATTCCTAGAAACCTGAAACATCGGAGT
    TATCTTACTACTCACAACCATAGCTACCGCGTTTATAGGCTACGTACTGCCATGAGGACAAATGTCATTC
    TGAGGGGCAACAGTCATTACCAACTTACTGTCAGCTATCCCCTATATTGGAACAGACCTAGTAGAATGAA
    TCTGAGGAGGCTTTTCCGTAGACAAAGCCACCCTTACACGATTCTTTGCCTTCCACTTTATTCTTCCATT
    CGTTATCACAGCACTAGCCATCGTCCATCTACTATTCCTCCATGAAACAGGATCCAACAACCCAACAGGA
    ATCCCCTCAAACGCAGACAAAATCCCATTCCACCCCTATTACACAATCAAGGACATCCTAGGTATCCTAC
    TCCTAATAACAACACTACTCACACTAACCTTATTTGCCCCAGACCTCCTAGGGGACCCAGACAACTACAC
    CCCCGCAAACCCCCTTAGCACACCACCACACATTAAACCAGAATGATATTTCCTGTTCGCGTACGCGATT
    CTCCGATCAATCCCCAACAAACTAGGAGGCGTCCTAGCCCTAGCTCTCTCAATCCTAATCCTGGCCCTAA
    TCCCAATACTACACACATCCAAACAACGAAGCCTAATATTTCGACCCCTCAGCCAATGCCTGTTTTGAGC
    ACTAATCGCCGACCTACTAACACTCACATGAATTGGAGGACAACCCGTCGAACACCCCTTCATCATCATC
    GGACAAGTCGCCTCAATCCTATATTTCCTCTTAATCTTAGTACTAATGCCCGTAGCAGGCATTATCGAAA
    ACAAACTCCTAAAATGAAGA

  2. #2
    Expert éminent

    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    4 300
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2008
    Messages : 4 300
    Points : 6 780
    Points
    6 780
    Par défaut
    Salut,

    C'est le traceback d'erreur complet qu'il faut copier ici.

    Tes explications ne correspondent pas aux lignes de code.

  3. #3
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut Veuillez m'escuser
    Je suis désoler de ne pas avoir les bonnes pratiques.
    Voilà ce que je peux vous proposer si c'est de cela que vous parliez.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    # -*- coding: utf-8 -*-
     
    import os, sys
     
    import re
     
    import numpy as np 
     
    from Bio import pairwise2
     
    import networkx as nx
     
     
    import matplotlib.pyplot as plt
     
    def network_project():
      File "<ipython-input-8-4b069aa68b05>", line 1
        def network_project():
                              ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    gene=[]     
     
    header=[]
     
    lecture=''
     
    i=0
     
    j=0
     
    file='exemple_sequence.txt'
     
    lecture=open(file,"r")      
     
    seq=''     
     
    for line in lecture:    
      File "<ipython-input-17-ee7616045115>", line 1
        for line in lecture:
                                ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    sequence=len(re.findall(r"[>]",line))   
    Traceback (most recent call last):
     
      File "<ipython-input-18-5b6993129435>", line 1, in <module>
        sequence=len(re.findall(r"[>]",line))
     
    NameError: name 'line' is not defined
     
     
     
     
    if(sequence>0):     
      File "<ipython-input-19-097ba0cab013>", line 1
        if(sequence>0):
                            ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    gene.append(seq)    
     
    seq=''
     
    sequence=0
     
    header.append(line[1:-1])  
    Traceback (most recent call last):
     
      File "<ipython-input-23-2c9773132d5f>", line 1, in <module>
        header.append(line[1:-1])
     
    NameError: name 'line' is not defined
     
     
     
     
    i=i+1
     
    else:
      File "<ipython-input-25-64c43b55f0b0>", line 1
        else:
           ^
    SyntaxError: invalid syntax
     
     
     
     
    seq=seq+line[:-1] 
    Traceback (most recent call last):
     
      File "<ipython-input-26-5ca41cc41d17>", line 1, in <module>
        seq=seq+line[:-1]
     
    NameError: name 'line' is not defined
     
     
     
     
    gene.append(seq)    
     
    lecture.close()   
     
    score=[]
     
    for i in range(len(gene)):
      File "<ipython-input-30-6371b26cf076>", line 1
        for i in range(len(gene)):
                                  ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    for j in range((i+1),len(gene)):
      File "<ipython-input-31-1264f3241f7e>", line 1
        for j in range((i+1),len(gene)):
                                        ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    score.append(pairwise2.align.globalms(gene[i],gene[j], 3, -2, -1, -.5,score_only=True))
     
    liste=[]
     
    seuil=(np.mean(score)+0.05*np.std(score))  
    C:\Users\Amandine\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py:2957: RuntimeWarning: Mean of empty slice.
      out=out, **kwargs)
    C:\Users\Amandine\Anaconda3\lib\site-packages\numpy\core\_methods.py:135: RuntimeWarning: Degrees of freedom <= 0 for slice
      keepdims=keepdims)
     
    s=0
     
    edge_labels={}
     
    for i in range(len(gene)):
      File "<ipython-input-37-6371b26cf076>", line 1
        for i in range(len(gene)):
                                  ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    for j in range((i+1),len(gene)):
      File "<ipython-input-38-1264f3241f7e>", line 1
        for j in range((i+1),len(gene)):
                                        ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    if(score[s]>seuil):
      File "<ipython-input-39-029433cbe1f7>", line 1
        if(score[s]>seuil):
                           ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    liste.append((header[i],header[j]))
    Traceback (most recent call last):
     
      File "<ipython-input-40-d41a38bfa2d3>", line 1, in <module>
        liste.append((header[i],header[j]))
     
    IndexError: list index out of range
     
     
     
     
    edge_labels[(header[i],header[j])]=score[s]
    Traceback (most recent call last):
     
      File "<ipython-input-41-aabbbf916451>", line 1, in <module>
        edge_labels[(header[i],header[j])]=score[s]
     
    IndexError: list index out of range
     
     
     
     
    s=s+1
     
    G=nx.Graph()
     
    G.add_nodes_from(header)
     
    G.add_edges_from(liste)
     
    pos=nx.spring_layout(G)
     
    node_s=[]
     
    t=0
     
    for t in range(len(gene)):
      File "<ipython-input-49-a4f1e5ab6d2b>", line 1
        for t in range(len(gene)):
                                  ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    node_s.append(20*np.log(len(seq[t])))
    Traceback (most recent call last):
     
      File "<ipython-input-50-b1d4c0a30894>", line 1, in <module>
        node_s.append(20*np.log(len(seq[t])))
     
    IndexError: string index out of range
     
     
     
     
    nx.draw_networkx_nodes(G,pos,node_color='green',label=True,alpha=1,node_size=node_s)
     
    
     
    Width=dict(edge_labels)
     
    for key,value in Width.items() :
      File "<ipython-input-53-2b9e3955cfe0>", line 1
        for key,value in Width.items() :
                                        ^
    SyntaxError: unexpected EOF while parsing
     
     
     
     
    Width[key] = np.log10(value)/2
    Traceback (most recent call last):
     
      File "<ipython-input-54-cbae24bb3a3e>", line 1, in <module>
        Width[key] = np.log10(value)/2
     
    NameError: name 'value' is not defined
     
     
     
     
    nx.draw_networkx_edges(G,pos,width=Width.values(),style='solid',edge_color='red',alpha=1)
     
    
     
    nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_labels,font_size=2,alpha=0.5,font_color='black')
    Out[56]: {}
    
     
    nx.draw_networkx_labels(G,pos,font_size=3,font_color='blue')
    Out[57]: {}
    
     
    namefordoc=input('Nom du PDF sans .pdf ?\n')
     
    Nom du PDF sans .pdf ?
    file
     
    plt.savefig(namefordoc+'.pdf')
    <Figure size 432x288 with 0 Axes>

    J'ai essayé de vous mettre le fichier .py du code ainsi que le fichier texte si celà peut vous aider
    temp.py exemple_sequence.txt

  4. #4
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,

    Les messages d'erreur signalent que vous utilisez IPython.
    C'est juste une interpréteur Python interactif (bien) amélioré.

    Ce que vous ne dites pas c'est comment votre script "arrive" dans IPython (en espérant que vous ne vous contentez pas d'un copie/coller).

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  5. #5
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    Bonsoir,
    j'utilise spyder à partir de anaconda, je tape mon code dans l’éditeur de texte et j'appuie sur le bouton "exécuter la ligne" et le "réponse" se trouve dans un interpréteur ipython.
    J'espère que ces informations complémentaires vous seront utiles.

  6. #6
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,

    Citation Envoyé par irishupk Voir le message
    J'espère que ces informations complémentaires vous seront utiles.
    Si je récupère le fichier script temp.py que vous avez posté tantôt et que j'essaie de le lancer chez moi, il n'y a pas de problème. Bon d'accord, je le lance après avoir créé un terminal et tapé "python script.py"... mais c'est quand même le mode d'exécution normal d'un script/programme Python: ce que vous faites avec Spyder, IPython,.... c'est juste utiliser des outils de création et de mise au point d'un code qui devra être exécuté sans (tous ces outils). Et si le script fonctionne "normalement" et pas avec vos outils , c'est que le soucis est plutôt côté utilisation ou configuration de vos outils (et non dans le script).

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

  7. #7
    Membre émérite

    Homme Profil pro
    Ingénieur calcul scientifique
    Inscrit en
    Mars 2013
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur calcul scientifique

    Informations forums :
    Inscription : Mars 2013
    Messages : 1 229
    Points : 2 328
    Points
    2 328
    Par défaut
    Citation Envoyé par irishupk Voir le message
    Bonsoir,
    j'utilise spyder à partir de anaconda, je tape mon code dans l’éditeur de texte et j'appuie sur le bouton "exécuter la ligne" et le "réponse" se trouve dans un interpréteur ipython.
    J'espère que ces informations complémentaires vous seront utiles.
    Il faut éxécuter le fichier en entier. Sous spyder c'est le symbole "play" vert, ou bien F5. Et non éxécuter la selection ou la ligne courante qui est F9.

  8. #8
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    Je vous remercie de votre aide et du temps que vous m'y avait consacré. Mon enseignent nous a demandé d'utiliser spyder pour nos projets mais comme vous devez le deviner, je ne le connaissais pas et visiblement je n'ais pas trouver le bon moyens d’exécuter mon script.
    Je vous remercie de vos explication et du temps que vous m'avez accordé.
    Cordialement

  9. #9
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    Citation Envoyé par lg_53 Voir le message
    Il faut éxécuter le fichier en entier. Sous spyder c'est le symbole "play" vert, ou bien F5. Et non éxécuter la selection ou la ligne courante qui est F9.
    Je vous remercie de votre explication, j'utiliser donc le mauvais bouton merci de m'aider à comprendre le programme spyder.

  10. #10
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    Citation Envoyé par wiztricks Voir le message
    Salut,



    Si je récupère le fichier script temp.py que vous avez posté tantôt et que j'essaie de le lancer chez moi, il n'y a pas de problème. Bon d'accord, je le lance après avoir créé un terminal et tapé "python script.py"... mais c'est quand même le mode d'exécution normal d'un script/programme Python: ce que vous faites avec Spyder, IPython,.... c'est juste utiliser des outils de création et de mise au point d'un code qui devra être exécuté sans (tous ces outils). Et si le script fonctionne "normalement" et pas avec vos outils , c'est que le soucis est plutôt côté utilisation ou configuration de vos outils (et non dans le script).

    - W
    Je vous remercie de vos explication, qui m'aideront à éxécuter mon fichier Merci !

  11. #11
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    Bonjour,
    Je me permet de me retourner vers vous, j'ai réussit à lancer mon script sans aucune erreur (après l'installation de nombreux paquets) mais lors de l’exécution, j'ai l'impression qu'il ne réalise pas le network et il ne me demande pas de nom pour le pdf.

    Savez vous pourquoi ?

    Cordialement

  12. #12
    Membre émérite

    Homme Profil pro
    Ingénieur calcul scientifique
    Inscrit en
    Mars 2013
    Messages
    1 229
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Ingénieur calcul scientifique

    Informations forums :
    Inscription : Mars 2013
    Messages : 1 229
    Points : 2 328
    Points
    2 328
    Par défaut
    Si votre code est le même que celui présenté dans le premier post, c'est normal.

    Tester le code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    def une_fonction():
        print("Toto")
    Est-ce que "toto" s'affiche dans votre terminal ?

    Et maintenant faite

    que se passe-t-il ?

    Il ne faut pas confondre la définition d'une fonction, et son appel. Si vous définissez une fonction sans y faire appel derrière alors nécéssairement, il ne se passe rien.

  13. #13
    Nouveau membre du Club
    Femme Profil pro
    etudiant
    Inscrit en
    Avril 2018
    Messages
    56
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 28
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : etudiant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2018
    Messages : 56
    Points : 32
    Points
    32
    Par défaut
    bonjour,

    En effet, vous avez raison, si on ne met pas la phrase d'appel, toto ne s'affiche pas.

    Je vous remercie !

Discussions similaires

  1. Réponses: 9
    Dernier message: 17/02/2016, 17h02
  2. SyntaxError: Unexpected EOF
    Par Anonyme1784 dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 03/07/2015, 17h32
  3. [1.x] syntax error, unexpected 'EOF'
    Par naimi atef dans le forum Débuter
    Réponses: 10
    Dernier message: 01/03/2011, 10h48
  4. [bcp] [very debutant] Unexpected EOF
    Par VASAPANCH dans le forum Outils
    Réponses: 1
    Dernier message: 28/04/2008, 19h07
  5. [XSLT] Error while parsing XSL file (unknown protocol: e)
    Par SONY30 dans le forum Format d'échange (XML, JSON...)
    Réponses: 1
    Dernier message: 26/09/2006, 13h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo