Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Errors trying to run code
I'm very new to python and received some help to create the code, but it isn't super complicated. I am receiving the following errors when trying to run the code.

File "C:\Users\Me\AppData\Local\Programs\Python\Python37\lib\", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\Me\AppData\Local\Programs\Python\Python37\lib\", line 85, in _run_code exec(code, run_globals) File "C:\Users\Me\Documents\GameProgramFolder\py_game\", line 85, in <module> main() File "C:\Users\Me\Documents\GameProgramFolder\py_game\", line 64, in main module = __import__(os.path.splitext(filename)[0]) File "C:\Users\Me\Documents\GameProgramFolder\py_game\", line 35, in exec_module exec(code, module.__dict__) File "C:\Users\Me\Documents\GameProgramFolder\Scripts\", line 3, in <module> import mylibrary File "C:\Users\Me\Documents\GameProgramFolder\py_game\", line 35, in exec_module exec(code, module.__dict__) File "C:\Users\Me\Documents\GameProgramFolder\py_game\", line 5, in <module> import requests ModuleNotFoundError: No module named 'requests'
I tried searching for a solution. I added the path environment, uninstalled python and reinstalled, and tried this solution: I don't know enough about what these errors mean to search for a better solution.
It's hard to figure out what you are trying to do.
try taking this one step at a time.
  • explain what the code is supposed to do
  • what the first step is that you are trying to do
  • The results of that step only.
  • code for the step.
Ok thank you for the response. I think the issue is something with my pc setup. My friend said they got the code to run for himself.

I'm playing a game that can be run with a client that supports python and has it's own library of functions native to the game. That's the py_game stuff. I have a library of functions that uses py_game and some things that I want to do in-game. The script I'm trying to run is supposed to attack the closest enemy.

I guess the first step is I'm trying to import the py_game library and mylibrary. Then search for all items within a range, filter to enemies, put them in a list, then determine which is closest to attack.

import py_game
import mylibrary

while True:
   searchList = mylibrary.findItems(-1,-1)
   attackables = []
   for it in searchList:
      if py_game.IsNPC(it):
         if it != py_game.Self() and py_game.GetNotoriety(it) > 2:

   closest = min(attackables,default=None,key=py_game.GetDistance)
   if closest:
The mylibrary starts with these imports if it's relevant:
import py_game
import threading
import enum
import time
import requests
import datetime

I think I've figured it out. With all the errors, I was in information overload, but needed to focus on the final line:

ModuleNotFoundError: No module named 'requests'
I added that in command line with python -m pip install requests and everything is working now.

According to this:

(Nov-03-2019, 03:48 AM)ziggyztz Wrote: The mylibrary starts with these imports if it's relevant:
import py_game
import threading
import enum
import time
import requests
import datetime

and the last lines of your error message:

(Nov-03-2019, 02:40 AM)ziggyztz Wrote:
import requests ModuleNotFoundError: No module named 'requests'

I would say that either you haven't installed the module 'requests' on your version of python or that you have more than one version of python installed.

To see what version of python you have installed, you can type python -V in your Windows command prompt (not sure if you are using Mac).

To install the module 'requests' in the version of python you are running, type pip install requests in your Windows command prompt.

Another thing that comes to mind is that according to the message from your link, it seems that it could be related to python 3.8 as I think I've read that some people are having trouble trying to run some modules on it.

All the best,


Great! It seems that you worked it out!

All the best,

"That's been one of my mantras - focus and simplicity. Simple can be harder than complex: You have to work hard to get your thinking clean to make it simple. But it's worth it in the end because once you get there, you can move mountains."
Steve Jobs

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  2 errors in code numbnumb54 2 219 Jul-24-2020, 02:28 PM
Last Post: Marbelous
  Code errors rhyjom 0 250 Jun-21-2020, 04:50 PM
Last Post: rhyjom
  [split] Kera Getting errors when following code example Image classification from scratch hobbyist 2 388 Jun-14-2020, 01:53 PM
Last Post: hobbyist
  Errors in code coolcassie 2 340 Dec-03-2019, 12:10 AM
Last Post: coolcassie
  errors in code sylvie1987100 3 565 Sep-11-2019, 12:54 PM
Last Post: sylvie1987100
  Decorator toy code throws syntax errors kevinxhi 3 1,269 Sep-04-2017, 03:01 AM
Last Post: kevinxhi

Forum Jump:

Users browsing this thread: 1 Guest(s)