title: Pip3 Install Module For All Users
body: <p>Not sure if I should be asking this here or over on Linux stack overflow but here it goes.</p>
  
  <p>I'm relatively new to python and I've been struggling to get this python script to autostart on an aws machine. I have two modules I need installed "discord.py" and "watson-cloud-developer". Pip3 installs the aforementioned modules with no error. When trying to run a service that runs a script that runs the python script (gotta love systemd) I get an error telling me that the discord module isn't installed, see below.</p>
  
  <p><a href="https://i.stack.imgur.com/lDQ3d.png" rel="nofollow noreferrer">Systemctl error</a></p>
  
  <pre><code>    ● discordbot.service
     Loaded: loaded (/etc/systemd/system/discordbot.service; static; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2019-03-03 17:16:00 UTC; 6s ago
    Process: 30567 ExecStart=/usr/local/sbin/startbot.sh (code=exited, status=1/FAILURE)
   Main PID: 30567 (code=exited, status=1/FAILURE)
  
  Mar 03 17:16:00 ip-172-31-46-72 systemd[1]: Started discordbot.service.
  Mar 03 17:16:00 ip-172-31-46-72 startbot.sh[30567]: Traceback (most recent call last):
  Mar 03 17:16:00 ip-172-31-46-72 startbot.sh[30567]:   File "/home/ubuntu/discordBot/main.py", line 1, in &lt;module&gt;
  Mar 03 17:16:00 ip-172-31-46-72 startbot.sh[30567]:     import discord
  Mar 03 17:16:00 ip-172-31-46-72 startbot.sh[30567]: ModuleNotFoundError: No module named 'discord'
  Mar 03 17:16:00 ip-172-31-46-72 systemd[1]: discordbot.service: Main process exited, code=exited, status=1/FAILURE
  Mar 03 17:16:00 ip-172-31-46-72 systemd[1]: discordbot.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/P1YrL.png" rel="nofollow noreferrer">Python3 proof that discord is installed</a></p>
  
  <pre><code>Python 3.6.7 (default, Oct 22 2018, 11:32:17)
  [GCC 8.2.0] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import discord
  &gt;&gt;&gt;
  </code></pre>
  
  <p>I'm more than happy to provide any additional info.</p>
  
  <p>EDITS:</p>
  
  <p>service:</p>
  
  <pre><code>[Service]
  ExecStart=/usr/local/sbin/startbot.sh
  </code></pre>
  
  <p>bash script:</p>
  
  <pre><code>#!/bin/bash
  python3 /home/ubuntu/discordBot/main.py
  </code></pre>
  
  <p>python scripts:</p>
  
  <pre><code>import json
  from watson_developer_cloud import VisualRecognitionV3
  
  visual_recognition = VisualRecognitionV3(
              "2018-03-19",
              iam_apikey="{api-key}")
  
  def ReturnWatsonResults(urlInput):
      classes_result = visual_recognition.classify(url=urlInput).get_result()
      imageResults = dict()
  
      for images in classes_result['images'][0]['classifiers'][0]['classes']:
          imageResults[images['class']]=str(images['score'] * 100)
  
      return imageResults
  </code></pre>
  
  <hr>
  
  <pre><code>import discord
  import watson
  from discord.ext.commands import Bot
  
  TOKEN = '{api-key}'
  
  BOT_PREFIX = ("!", "$")
  
  client = Bot(command_prefix=BOT_PREFIX)
  
  @client.command(name="Memealyze",
          description="Send your favorite meme and the boys at IBM will get to work telling you what they see",
          brief="Neural network put to good use",
          pass_context=True)
  async def GetMemeContents(context):
      await client.say("Sending image to the mothership, hold tight")
  
      messageContent = ""
      imageUrl = str(context.message.attachments[0]['url'])
      resultDict = watson.ReturnWatsonResults(imageUrl)
  
      for key,val in resultDict.items():
          messageContent += (key + ":" + val + "%" + "\n")
  
      await client.say("Done, the boys at IBM said they found this:\n" + messageContent)
  
  client.run(TOKEN)
  </code></pre>
  
  <p>I know that the python scripts aren't very well written but they do work, the current hitch in the giddy up lies solely in where pip is installing the modules, for one reason or another they can't be accessed when being ran by systemd.</p>