0

I just don't understand why my code generates the error message:

'import sitecustomize' failed

Here's the code:

from numpy import *
from pycalfem import *
from pycalfem_utils import *
def createInput():
edof=array([[1,2,3,4,5,6],
            [1,2,7,8,3,4],
            [3,4,7,8,9,10],
            [7,8,11,12,9,10]])
dof=array([[1,2],
          [5,6],
          [7,8],
          [3,4],
          [11,12],
          [9,10]])
Coord=array([[0,0],
             [0,0.1],
             [0.1,0],
             [0.1,0.1],
             [0.2,0],
             [0.2,0.1]])
bc=array([[1,0],[2,0],[4,0],[5,0]])
ex,ey=coordxtr(edof,Coord,dof)
return ex,ey,bc,edof

if __name__=="main":
print("Hej")
ex,ey,bc,edof=createInput()
Ajean
  • 5,528
  • 14
  • 46
  • 69
Sam
  • 5
  • 2
  • Notice that your indentation in the main block is messed up, if that's what it actually looks like. – Ajean Mar 31 '15 at 18:14
  • 1
    `from module import *` is a bad way of importing modules as it pollutes your namespace. Rather import the entire module or just the class / functions you need – letsc Mar 31 '15 at 18:22
  • agree with @letsc - better to do something like `import numpy as np` if you want to shorten – Harold Ship Mar 31 '15 at 18:26
  • Ok, so rather "import numpy" than "from numpy import * " ? Also, if i comment all the code so theres nothing written, spyder still gives me the same error message. And I just tried the "import numpy" version and it didnt help. – Sam Mar 31 '15 at 18:31
  • 1
    Can you give the full error message? – TheBlackCat Mar 31 '15 at 18:54
  • sure! 'import sitecustomize' failed; use -v for traceback >>> – Sam Mar 31 '15 at 19:08
  • Is the error something along these lines? https://code.google.com/p/spyderlib/issues/detail?id=771 (On second look it appears that this message comes up with a lot of errors. I would suggest you do as it says and use `-v` for a traceback then add the traceback to your question.) –  Mar 31 '15 at 19:32
  • Ok, so I configured my module to "execute in an external system terminal" instead of, as before, "execute in a new dedicated Python interpreter" and now it runs if i change to (if __name__ !="main"), How can i run it if its (if __name__=="main") instead? – Sam Mar 31 '15 at 23:00

1 Answers1

0

try

python -v

which will tell you why sitecustomize failed to import.

Barry Rogerson
  • 598
  • 2
  • 15
  • 1
    I'm not sure this qualifies as a full on answer. (It feels more comment-like.) –  Mar 31 '15 at 20:47
  • Im such a noob on python.. So back to basics, im using winPython and running it with Spyder. So where do I type in python -v ? – Sam Mar 31 '15 at 22:50
  • @Sam .. it looks like you'll need to hack the registry to add an argument http://stackoverflow.com/a/2641185/4275865 – Barry Rogerson Apr 01 '15 at 21:20