pmariglia / showdown

A Pokemon Showdown Battle Bot written in Python
GNU General Public License v3.0
254 stars 176 forks source link

Environs not recognized? #170

Closed Pixeluchiha closed 1 year ago

Pixeluchiha commented 1 year ago

I get the following error when I try to run.py. I just downloaded the newest build of the project, as my old one was very outdated. Added my teams, changed the "env" file to a .env, put the master folder into my python folder, installed the requirements.txt, then ran the run.py. I tried figuring it out myself, but I just don't know why this error is showing up, as everything looks correct. Only thing I can guess is something to do with the "environs.py", but I never had to mess with that up until this point, so I don't know what to do there to resolve anything. Screenshot (81) Screenshot (83)

pmariglia commented 1 year ago

Did you not save your file?

The editor shows *.env, which usually indicates you have outstanding changes in the editor that you did not save to disk.

Pixeluchiha commented 1 year ago

I did have it saved. I left it unsaved in the screenshot so I can close it without having to reinput my login information. I even tried it using old .env settings that used to work, and it gives the same error. My leading theory is that it is an outdated repository, but I don't know how I would update the repository, as every time I try to clone it it tells me it already exists and is not empty. I don't really have any basis for this theory, though, just that I went through all the steps again of installing the code, yet I can't change that one step because the directory already exists.

Pixeluchiha commented 1 year ago

My leading theory is that it is an outdated repository, but I don't know how I would update the repository, as every time I try to clone it it tells me it already exists and is not empty. I don't really have any basis for this theory, though, just that I went through all the steps again of installing the code, yet I can't change that one step because the directory already exists.

I was able to clear the old directory and clone the repository, but I still get the same error, so it seems that wasn't the issue.

Pixeluchiha commented 1 year ago

Was looking at the config file to see the differences between it and an older one I downloaded in 2021, and now I'm thinking that the issue has something to do with the "config" file or "run", considering the significant changes it seems to have, the main one seeming to be the addition of "ShowdownConfig". I don't exactly know anything still, so the config could mean nothing. I would think I should be able to download the files and run the code like normal considering no one else has any issues like this it seems, so I think it is because I used to use an older version?

pmariglia commented 1 year ago

Oh - I believe your terminal is in the home directory of your user (the blanked out name).

You may need to change directories to be in the same folder as the bot (showdown-master)

Pixeluchiha commented 1 year ago

I apologize if I'm slow to understand things, I'm new to things like this. Could you tell me how to change directories? The showdown-master folder is within the user folder, and in no other place. There is also a "showdown" folder within the blanked out user folder that was cloned from the repository. Would it help to send a screenshot or do you not need it?

Pixeluchiha commented 1 year ago

I'll also include that this is the command I use to run the python: "python C:\Users\blank\Pixeluchiha\Python-3.9\showdown-master\run.py"

pmariglia commented 1 year ago

Take a look at this: https://www.howtogeek.com/659411/how-to-change-directories-in-command-prompt-on-windows-10/

You want to be in the showdown-master directory, and then run python run.py

Pixeluchiha commented 1 year ago

Screenshot (89) I'm still getting the same error: environs.EnvError: Environment variable "BATTLE_BOT" not set

pmariglia commented 1 year ago

I just booted up my windows machine as was able to get it working with the following steps using Python 3.9.

  1. Download the source code, put into my Documents folder
  2. Open Command-Prompt
  3. Navigate to the showdown-master folder with cd Documents and then cd showdown-master
  4. Install requirements with pip install -r requirements.txt
  5. Edit the env file in Notepad to the following (be sure to save it with cntrl+s):
    
    BATTLE_BOT=safest
    WEBSOCKET_URI=sim.smogon.com:8000
    PS_USERNAME=<REDACTED>
    PS_PASSWORD=<REDACTED>
    BOT_MODE=SEARCH_LADDER
    POKEMON_MODE=gen9randombattle
    RUN_COUNT=1

USER_TO_CHALLENGE=SomeOtherPerson TEAM_NAME=gen8/ou/clef_sand SAVE_REPLAY=False

6. Run with `python run.py`

The bot runs just fine. Terminal output up until the battle starts:

C:\Users\XX>cd Documents

C:\Users\XX\Documents>cd showdown-master

C:\Users\XX\Documents\showdown-master>python run.py Traceback (most recent call last): File "C:\Users\XX\Documents\showdown-master\run.py", line 9, in from config import ShowdownConfig, init_logging File "C:\Users\XX\Documents\showdown-master\config.py", line 7, in from environs import Env ModuleNotFoundError: No module named 'environs'

C:\Users\X\Documents\showdown-master>where pip C:\Users\XX\AppData\Local\Microsoft\WindowsApps\pip.exe

C:\Users\XX\Documents\showdown-master>pip install -r requirements.txt Collecting requests==2.31.0 Downloading requests-2.31.0-py3-none-any.whl (62 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 62.6/62.6 KB ? eta 0:00:00 Collecting environs==4.1.0 Downloading environs-4.1.0-py2.py3-none-any.whl (8.7 kB) Collecting websockets==10.3 Downloading websockets-10.3-cp39-cp39-win_amd64.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.6/98.6 KB ? eta 0:00:00 Collecting python-dateutil==2.8.0 Downloading python_dateutil-2.8.0-py2.py3-none-any.whl (226 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 226.8/226.8 KB ? eta 0:00:00 Collecting certifi>=2017.4.17 Downloading certifi-2023.7.22-py3-none-any.whl (158 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 158.3/158.3 KB 9.9 MB/s eta 0:00:00 Collecting idna<4,>=2.5 Downloading idna-3.4-py3-none-any.whl (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.5/61.5 KB 3.4 MB/s eta 0:00:00 Collecting urllib3<3,>=1.21.1 Downloading urllib3-2.0.4-py3-none-any.whl (123 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.9/123.9 KB 7.6 MB/s eta 0:00:00 Collecting charset-normalizer<4,>=2 Downloading charset_normalizer-3.2.0-cp39-cp39-win_amd64.whl (96 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 96.9/96.9 KB 5.8 MB/s eta 0:00:00 Collecting marshmallow>=2.7.0 Downloading marshmallow-3.20.1-py3-none-any.whl (49 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 49.4/49.4 KB ? eta 0:00:00 Collecting python-dotenv Downloading python_dotenv-1.0.0-py3-none-any.whl (19 kB) Collecting six>=1.5 Downloading six-1.16.0-py2.py3-none-any.whl (11 kB) Collecting packaging>=17.0 Downloading packaging-23.1-py3-none-any.whl (48 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 48.9/48.9 KB ? eta 0:00:00 Installing collected packages: websockets, urllib3, six, python-dotenv, packaging, idna, charset-normalizer, certifi, requests, python-dateutil, marshmallow, environs WARNING: The script dotenv.exe is installed in 'C:\Users\XX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script normalizer.exe is installed in 'C:\Users\XX\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed certifi-2023.7.22 charset-normalizer-3.2.0 environs-4.1.0 idna-3.4 marshmallow-3.20.1 packaging-23.1 python-dateutil-2.8.0 python-dotenv-1.0.0 requests-2.31.0 six-1.16.0 urllib3-2.0.4 websockets-10.3 WARNING: You are using pip version 22.0.4; however, version 23.2.1 is available. You should consider upgrading via the 'C:\Users\XX\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe -m pip install --upgrade pip' command.

C:\Users\XX\Documents\showdown-master>python run.py [DEBUG] Logging in... [DEBUG] Received message from websocket: |updateuser| Guest 9274268|0|170|{"blockChallenges":false,"blockPMs":false,"ignoreTickets":false,"hideBattlesFromTrainerCard":false,"blockInvites":false,"doNotDisturb":false,"blockFriendRequests":false,"allowFriendNotifications":false,"displayBattlesToFriends":false,"hideLogins":false,"hiddenNextBattle":false,"inviteOnlyNextBattle":false,"language":null} |formats|,1|S/V Singles|[Gen 9] Random Battle,f|[Gen 9] Unrated Random Battle,b|[Gen 9] Free-For-All Random Battle,7|[Gen 9] Random Battle (Blitz),f|[Gen 9] Multi Random Battle,5|[Gen 9] OU,e|[Gen 9] Ubers,e|[Gen 9] UU,e|[Gen 9] RU,e|[Gen 9] NU,e|[Gen 9] PU,e|[Gen 9] LC,e|[Gen 9] Monotype,e|[Gen 9] 1v1,e|[Gen 9] Anything Goes,e|[Gen 9] NFE,e|[Gen 9] ZU,e|[Gen 9] LC UU,c|[Gen 9] CAP,e|[Gen 9] Free-For-All,6|[Gen 9] Battle Stadium Singles Regulation C,1c|[Gen 9] Battle Stadium Singles Regulation D,1e|[Gen 9] Custom Game,c|,1|S/V Doubles|[Gen 9] Random Doubles Battle,f|[Gen 9] Doubles OU,e|[Gen 9] Doubles Ubers,e|[Gen 9] Doubles UU,e|[Gen 9] Doubles LC,e|[Gen 9] 2v2 Doubles,e|[Gen 9] VGC 2023 Regulation C,1c|[Gen 9] VGC 2023 Regulation D,1e|[Gen 9] Doubles Custom Game,c|,1|National Dex|[Gen 9] National Dex,e|[Gen 9] National Dex Ubers,e|[Gen 9] National Dex UU,e|[Gen 9] National Dex RU,c|[Gen 9] National Dex Monotype,e|[Gen 9] National Dex AG,c|[Gen 9] National Dex Doubles,e|[Gen 9] National Dex BH,c|,1|Pet Mods|[Gen 8] JolteMons Random Battle,f|[Gen 6] NEXT OU,8|,1|Draft|[Gen 9] Paldea Dex Draft,c|[Gen 9] Tera Preview Paldea Dex Draft,c|[Gen 9] 6v6 Doubles Draft,c|[Gen 9] 4v4 Doubles Draft,1c|[Gen 9] NatDex Draft,c|[Gen 9] Tera Preview NatDex Draft,c|[Gen 9] NatDex 6v6 Doubles Draft,c|[Gen 9] NatDex 4v4 Doubles Draft,1c|[Gen 9] NatDex LC Draft,c|[Gen 8] Galar Dex Draft,c|[Gen 8] NatDex Draft,c|[Gen 8] NatDex 4v4 Doubles Draft,1c|[Gen 7] Draft,c|[Gen 6] Draft,c|,2|OM of the Month|[Gen 9] 350 Cup,e|[Gen 9] Bonus Type,e|,2|Other Metagames|[Gen 9] Almost Any Ability,e|[Gen 9] Balanced Hackmons,e|[Gen 9] Pre-Full Dex BH,c|[Gen 9] Mix and Mega,e|[Gen 9] Godly Gift,e|[Gen 9] STABmons,e|,2|Challengeable OMs|[Gen 9] Camomons,c|[Gen 9] Convergence,c|[Gen 9] Cross Evolution,c|[Gen 9] Fortemons,c|[Gen 9] Full Potential,c|[Gen 9] Partners in Crime,c|[Gen 9] Inheritance,c|[Gen 9] Pokebilities,c|[Gen 9] Pure Hackmons,c|[Gen 9] Revelationmons,c|[Gen 9] Shared Power,c|[Gen 9] Tera Donation,c|[Gen 9] The Card Game,c|[Gen 9] The Loser's Game,c|[Gen 9] Trademarked,c|,2|Retro Other Metagames|[Gen 6] Pure Hackmons,e|,3|Randomized Format Spotlight|[Gen 9] Random Roulette,f|,3|Randomized Metas|[Gen 9] Monotype Random Battle,f|[Gen 9] Random Battle Mayhem,f|[Gen 9] Computer-Generated Teams,f|[Gen 9] Hackmons Cup,f|[Gen 9] Doubles Hackmons Cup,d|[Gen 9] Broken Cup,d|[Gen 9] Challenge Cup 1v1,f|[Gen 9] Challenge Cup 2v2,f|[Gen 9] Challenge Cup 6v6,d|[Gen 8] Random Battle,f|[Gen 8] Random Doubles Battle,f|[Gen 8] Free-For-All Random Battle,7|[Gen 8] Multi Random Battle,5|[Gen 8] Battle Factory,f|[Gen 8] BSS Factory,1f|[Gen 8] Super Staff Bros 4,f|[Gen 8] Hackmons Cup,f|[Gen 8] CAP 1v1,d|[Gen 8 BDSP] Random Battle,d|[Gen 7] Random Battle,f|[Gen 7] Random Doubles Battle,9|[Gen 7] Battle Factory,f|[Gen 7] BSS Factory,1d|[Gen 7] Hackmons Cup,d|[Gen 7 Let's Go] Random Battle,d|[Gen 6] Random Battle,f|[Gen 6] Battle Factory,9|[Gen 5] Random Battle,f|[Gen 4] Random Battle,f|[Gen 3] Random Battle,f|[Gen 2] Random Battle,f|[Gen 1] Random Battle,f|[Gen 1] Challenge Cup,9|[Gen 1] Hackmons Cup,9|,3|Metronome Battle|[Gen 9] Metronome Battle,e|[Gen 8] Metronome Battle,c|,4|RoA Spotlight|[Gen 3] Ubers,e|[Gen 3] LC,e|[Gen 7 Let's Go] OU,1e|,4|Past Gens OU|[Gen 8] OU,e|[Gen 7] OU,e|[Gen 6] OU,e|[Gen 5] OU,e|[Gen 4] OU,e|[Gen 3] OU,e|[Gen 2] OU,e|[Gen 1] OU,e|,4|Past Gens Doubles OU|[Gen 8] Doubles OU,e|[Gen 7] Doubles OU,e|[Gen 6] Doubles OU,e|[Gen 5] Doubles OU,c|[Gen 4] Doubles OU,e|[Gen 3] Doubles OU,c|,4|Sw/Sh Singles|[Gen 8] Ubers,c|[Gen 8] UU,c|[Gen 8] RU,c|[Gen 8] NU,c|[Gen 8] PU,c|[Gen 8] LC,c|[Gen 8] Monotype,c|[Gen 8] 1v1,c|[Gen 8] Anything Goes,c|[Gen 8] ZU,c|[Gen 8] CAP,c|[Gen 8] National Dex,c|[Gen 8] National Dex UU,c|[Gen 8] Battle Stadium Singles,1c|[Gen 8 BDSP] OU,c|[Gen 8] Custom Game,c|,5|Sw/Sh Doubles|[Gen 8] Doubles Ubers,c|[Gen 8] Doubles UU,c|[Gen 8] VGC 2022,1c|[Gen 8] VGC 2021,1c|[Gen 8] VGC 2020,1c|[Gen 8 BDSP] Doubles OU,c|[Gen 8 BDSP] Battle Festival Doubles,1c|[Gen 8] Doubles Custom Game,c|,5|US/UM Singles|[Gen 7] Ubers,c|[Gen 7] UU,c|[Gen 7] RU,c|[Gen 7] NU,c|[Gen 7] PU,c|[Gen 7] LC,c|[Gen 7] Monotype,c|[Gen 7] 1v1,c|[Gen 7] Anything Goes,c|[Gen 7] ZU,c|[Gen 7] CAP,c|[Gen 7] Battle Spot Singles,1c|[Gen 7] Custom Game,c|,5|US/UM Doubles|[Gen 7] Doubles UU,c|[Gen 7] VGC 2019,1c|[Gen 7] VGC 2018,1c|[Gen 7] VGC 2017,1c|[Gen 7] Battle Spot Doubles,1c|[Gen 7 Let's Go] Doubles OU,c|[Gen 7] Doubles Custom Game,c|,6|OR/AS Singles|[Gen 6] Ubers,c|[Gen 6] UU,c|[Gen 6] RU,c|[Gen 6] NU,c|[Gen 6] PU,c|[Gen 6] LC,c|[Gen 6] Monotype,c|[Gen 6] 1v1,c|[Gen 6] Anything Goes,c|[Gen 6] ZU,c|[Gen 6] CAP,c|[Gen 6] Battle Spot Singles,1c|[Gen 6] Custom Game,c|,6|OR/AS Doubles/Triples|[Gen 6] VGC 2016,1c|[Gen 6] VGC 2015,1c|[Gen 6] VGC 2014,1c|[Gen 6] Battle Spot Doubles,1c|[Gen 6] Doubles Custom Game,c|[Gen 6] Battle Spot Triples,1c|[Gen 6] Triples Custom Game,c|,6|B2/W2 Singles|[Gen 5] Ubers,c|[Gen 5] UU,c|[Gen 5] RU,c|[Gen 5] NU,c|[Gen 5] PU,c|[Gen 5] LC,c|[Gen 5] Monotype,c|[Gen 5] 1v1,c|[Gen 5] ZU,c|[Gen 5] CAP,c|[Gen 5] GBU Singles,1c|[Gen 5] Custom Game,c|,6|B2/W2 Doubles|[Gen 5] VGC 2013,1c|[Gen 5] VGC 2012,1c|[Gen 5] VGC 2011,1c|[Gen 5] Doubles Custom Game,c|[Gen 5] Triples Custom Game,c|,7|DPP Singles|[Gen 4] Ubers,c|[Gen 4] UU,c|[Gen 4] NU,c|[Gen 4] PU,c|[Gen 4] LC,c|[Gen 4] Anything Goes,c|[Gen 4] 1v1,c|[Gen 4] ZU,c|[Gen 4] CAP,c|[Gen 4] Custom Game,c|,7|DPP Doubles|[Gen 4] VGC 2010,1c|[Gen 4] VGC 2009,1c|[Gen 4] Doubles Custom Game,c|,7|Past Generations|[Gen 3] UU,c|[Gen 3] NU,c|[Gen 3] PU,c|[Gen 3] 1v1,c|[Gen 3] Custom Game,c|[Gen 3] Doubles Custom Game,c|[Gen 2] Ubers,c|[Gen 2] UU,c|[Gen 2] NU,c|[Gen 2] 1v1,c|[Gen 2] Nintendo Cup 2000,c|[Gen 2] Stadium OU,c|[Gen 2] Custom Game,c|[Gen 1] Ubers,c|[Gen 1] UU,c|[Gen 1] NU,c|[Gen 1] PU,c|[Gen 1] 1v1,c|[Gen 1] Japanese OU,c|[Gen 1] Stadium OU,c|[Gen 1] Tradebacks OU,c|[Gen 1] Nintendo Cup 1997,c|[Gen 1] Custom Game,c

[DEBUG] Successfully logged in [DEBUG] Searching for ranked gen9randombattle match ...

Pixeluchiha commented 1 year ago

This worked for me, thank you! I don't quite understand what wasn't working with the old file path, but I am happy you helped me figure this out! (Just checked again, seems like it will only work if the directory is within showdown-master, and wont work if it just points to it)

Pixeluchiha commented 1 year ago

Now I'm going to test if my other issue, removing Tera and Dynamax, is also resolved.