title: inverse matrix Python3 mpi4py EOFError: EOF when reading a line
body: <p>I'm writing a piece of code that will inverse a matrix with the use of <code>mpi4py</code>. I'm getting an error that's giving me issues.</p>
  
  <p>I put 2 default variables <code>m, n</code> and the user inserts the numbers into the <code>rank 0</code> process to fill the matrix. The process <code>rank 0</code> sends the matrix  to the <code>process 1</code> and <code>process 2</code>. In <code>process 1</code> I initialize the matrix and the determinant, calculate the determinant, and send it back to <code>rank 0</code>. In <code>process 2</code>, I initialize the matrix, find the inverse matrix, and send back the inverse matrix to the process 0.</p>
  
  <p>In <code>process 0</code> I then receive the determinant and the inverse matrix. If the determinant is 0, a message will be sent and the program will exit (the inverse matrix can be calculated even if the determinant is 0, but it's not correct). If it's not 0, the program will print the inverse matrix.</p>
  
  <p>Note that I know the current implementation is not the best way to parallelize this problem, but I needed to start from somewhere.</p>
  
  <p>The determinant was giving me some errors so I initialized it as an empty <code>numpy</code> array of 2 elements, where the first element is the determinant and the second is 0. I edited the code a bit from my native language to English so it could be read and understood easier, therefore it may contain some errors.</p>
  
  <p>The problem is that when I want to give the user the privilege to write the matrix size. I checked some related answers, and have tried using <code>map()</code>, <code>raw_input()</code>, and other options, but none have worked.</p>
  
  <p>The code:</p>
  
  <pre><code>import numpy as np
  from numpy.linalg import inv
  from scipy.linalg import det
  from mpi4py import MPI
  
  
  
  comm = MPI.COMM_WORLD
  rank = comm.Get_rank()
  size = comm.Get_size()
  
  m = int(input())
  n = int(input())
  
  if rank==0:
      matrix = np.zeros((m,n))
      determinant = np.zeros((2))
      for i in range (0,m):
          for j in range(0,n):
              print("Enter the value for the field: m = ", i+1, ", n = ", j+1,"\n")
              matrix[i][j] = float(input())
  
      comm.Send(matrix, dest=1, tag=0)
      comm.Send(matrix, dest=2, tag=0)
      comm.Recv(determinant, source=1, tag=0)
      comm.Recv(matrix, source=2, tag=0)
      if(determinant[0]==0):
          print("There is no inverse matrix since the determinant is 0!")
      else:
          print("Inverse matrix:\n",matrica)
  elif rank==1:
      matrix = np.zeros((m,n))
      determinant = np.zeros((2))
      comm.Recv(matrix, source=0, tag=0)
      determinant = np.array([[det(matrix)],[0]])
      comm.Send(determinant, dest=0)
  elif rank==2:
      matrix = np.zeros((m,n))
      comm.Recv(matrix, source=0, tag=0)
      matrix = inv(matrix)
      comm.Send(matrix, dest=0)
  else:
      exit()
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "lambda.py", line 13, in &lt;module&gt;
      m = int(input())
  EOFError: EOF when reading a line
  Traceback (most recent call last):
    File "lambda.py", line 13, in &lt;module&gt;
      m = int(input())
  EOFError: EOF when reading a line
  </code></pre>
  
  <p>EDIT:
  I'm using PuTTY to connect to a Debian OS from the university.</p>
  
  <p>Interpreter version: sys.version_info(major=3, minor=5, micro=1, releaselevel='final', serial=0)</p>
  
  <p>I enter the command line: mpirun -np 3 python3 lambda.py, I get an EoFError and insert the numbers till the point where it should do something, when instead of doing it, it continues to run as an infinite loop.(Better seen in the picture)
  <a href="http://i.stack.imgur.com/s866j.png" rel="nofollow">Picture</a></p>
  
  <p>Added the code to trace the input: </p>
  
  <pre><code>m = int(input("Enter number of rows, m = \n"))
  n = int(input("Enter number of columns, n = \n"))
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/jirqb.png" rel="nofollow">Picture 2</a></p>