title: sudo privileges within python virtualenv
body: <h3>Environment</h3>
  
  <ul>
  <li><p><code>Windows Subsystem for Linux</code> with Serial Communication to a GPS.</p></li>
  <li><p>Adafruit GPS connected to a Arduino Nano which is connected to <code>COM10</code>. In <code>Windows Subsystem for Linux</code> this is equivalent to <code>/dev/ttyS10</code></p></li>
  <li><p>Requirements: <code>pyserial</code></p></li>
  </ul>
  
  <p>I have written a simple script to read information from the GPS module:</p>
  
  <pre><code>import serial
  
  def select_sentence():
  """ This function sends serial data to the GPS module to display only GPGGA and GPRMC"""
  
  def read_gps():
      ser = serial.Serial("/dev/ttyS10", 9600)
      while True:
           print(ser.readline().decode('utf-8'))
  
  if __name__ == "__main__":
       select_sentence()
       read_gps()
  </code></pre>
  
  <p>In the virtualenv I chose <code>Python3</code> and when I executed it I got <code>Permission Error</code> for the serial port <code>/ttyS10</code> so I chose to <code>sudo chmod 666 /dev/ttyS10</code> to use the script in the <code>virtualenv</code>. </p>
  
  <p>However is there an alternative to the above mentioned <code>chmod /dev/serial</code> in order to avoid the <code>PermissionErrors</code>?</p>
  
  <p>I am aware that even in the <code>virtualenv</code> when one uses <code>sudo</code> the packages installed in the virtualenv are no considered and instead sudo looks for your global <code>pip</code> packages.</p>