Ml-agents: ModuleNotFoundError: No module named 'win32api'

Created on 19 Oct 2018  ยท  28Comments  ยท  Source: Unity-Technologies/ml-agents

So I've tried to run the learn.py program using the following command:
mlagents-learn /config/config_trainer.yaml --train --run-id=test

However, it keeps returning this error:
Traceback (most recent call last):
File "c:users\jpste\anaconda3\envs\ml-agents\librunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:users\jpste\anaconda3\envs\ml-agents\librunpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\jpste\Anaconda3\envs\ml-agents\Scripts\mlagents-learn.exe__main__.py", line 5, in
File "c:users\jpste\anaconda3\envs\ml-agents\lib\site-packages\mlagents\trainers\learn.py", line 9, in
from trainer_controller import TrainerController
ModuleNotFoundError: No module named 'trainer_controller'

I followed the instructions as told multiple times, restarting a few instances, yet I keep getting this error. I'm honestly lost as to what I did wrong at this point...

bug help-wanted

Most helpful comment

I ran into this as well on Windows 10 64bit using ml-agents 0.6.
I would suggest adding the "pip install pypiwin32" command to Installation-Windows.md.

All 28 comments

Hi @TrollOfAllTrolls,

Can you let me know what platform you are using, and how you installed the mlagents python package?

Oh right, I should have clarified that I'm using windows. I used Anaconda to install the mlagents python package, first creating the ml-agents environment. I then installed all the necessary content from the requirements file in the ml-agents folder

@awjuliani

Hi @TrollOfAllTrolls

We have updated our installation process for v0.6, could you try it using the new system and see if the error persists?

Hello,
Excuse me for jumping in, but, this is wigging me out. I also have an Anaconda, tensorflow installation and I went back to 2017.4.18 which seems the safest. I was working with 2018.2.14 and actually had better luck in that in one shining moment I was able to connect with 3DBall environment but could never get it to repeat the trick.

Here's a python log which has me in a choke hold :
(ml-agents) c:\Users\msi\Downloads\ml-agents>mlagents-learn C:\Users\msi\Downloads\ml-agents\config\trainer_config.yaml --env=3DBall --train
Traceback (most recent call last):
File "C:\Users\msi\Anaconda3\envs\ml-agents\Scriptsmlagents-learn-script.py", line 11, in
load_entry_point('mlagents', 'console_scripts', 'mlagents-learn')()
File "C:\Users\msi\Anaconda3\envs\ml-agents\lib\site-packages\pkg_resources__init__.py", line 487, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Users\msi\Anaconda3\envs\ml-agents\lib\site-packages\pkg_resources__init__.py", line 2728, in load_entry_point
return ep.load()
File "C:\Users\msi\Anaconda3\envs\ml-agents\lib\site-packages\pkg_resources__init__.py", line 2346, in load
return self.resolve()
File "C:\Users\msi\Anaconda3\envs\ml-agents\lib\site-packages\pkg_resources__init__.py", line 2352, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:users\msi\downloads\ml-agents\ml-agentsmlagents\trainers__init__.py", line 5, in
from .trainer_controller import *
File "c:users\msi\downloads\ml-agents\ml-agentsmlagents\trainers\trainer_controller.py", line 11, in
import win32api
ModuleNotFoundError: No module named 'win32api'

Any pointers or comments would be greatly appreciated.

Thanks!

@whiteGhost333 Which version of the code are you using and which platform are you running this on?

Oh I was able to reproduce this. You just need to type "pip install pypiwin32" to fix this. I will put a fix for this.

windows pro 10, 2017.4.18, tensorflow 1.7.1 python 3.6 & ml-agents 0.6.

I'll give the command stream a go.

On Tue, Jan 15, 2019, 6:17 PM Vincent(Yuan) Gao <[email protected]
wrote:

Oh I was able to reproduce this. You just need to type "pip install
pypiwin32" to fix this. I will put a fix for this.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-454625950,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzIICnurQ3bA5UERLGPn7vcZFkaJ0ks5vDovFgaJpZM4Xvmce
.

Below are the results in anaconda. It was apparently the command was successful, but, an even more baffling error occurred...

(base) C:\Users\msi>activate ml-agents

(ml-agents) C:\Users\msi>pip install pypiwin32
Collecting pypiwin32
Downloading https://files.pythonhosted.org/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3-none-any.whl
Collecting pywin32>=223 (from pypiwin32)
Downloading https://files.pythonhosted.org/packages/b2/1a/7727b406391b0178b6ccb7e447e963df5ebf1ce9e0f615fc6ce23b6f6753/pywin32-224-cp36-cp36m-win_amd64.whl (9.1MB)
100% |โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 9.1MB 2.3MB/s
Installing collected packages: pywin32, pypiwin32
Successfully installed pypiwin32-223 pywin32-224

(ml-agents) C:\Users\msi>c:\Users\msi\Downloads\ml-agents>mlagents-learn C:\Users\msi\Downloads\ml-agents\config\trainer_config.yaml --env=3DBall --train
'c:\Users\msi\Downloads\ml-agents' is not recognized as an internal or external command,
operable program or batch file.

@whiteGhost333 Can you post a snapshot of the message you see?

@xiaomaogy It is in the tail end of my last message.

Here is a newer one from my last attempt.

(ml-agents) C:\Users\msi>(ml-agents) C:\Users\msi>c:\Users\msi\Downloads\ml-agents>mlagents-learn C:\Users\msi\Downloads\ml-agents\config\trainer_config.yaml --env=3DBall --train
C:\Users\msi was unexpected at this time.

@whiteGhost333 It seems that the error message you received says your path C:\Users\msi doesn't exist or something similar.

Not really...

(base) C:\Users\msi>activate ml-agents

(ml-agents) C:\Users\msi>cd
C:\Users\msi

(ml-agents) C:\Users\msi>conda info --envs

conda environments:

#
base C:\Users\msi\Anaconda3
ml-agents * C:\Users\msi\Anaconda3\envs\ml-agents

(ml-agents) C:\Users\msi>

On Wed, Jan 16, 2019 at 1:40 PM Vincent(Yuan) Gao notifications@github.com
wrote:

@whiteGhost333 https://github.com/whiteGhost333 It seems that the error
message you received says your path C:\Users\msi doesn't exist or something
similar.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-454953517,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzMtN7-fq7CXjTUrLhsEMP8MW3uGgks5vD5xigaJpZM4Xvmce
.

This might also be because your "mlagents-learn" command hasn't been installed correctly. Have you done "pip install . " within your ml-agents folder that contains setup.py? Has the ml-agents 0.6 python package been installed successfully?

I was planning on doing a reinstall in order to compare the results. I
have do a couple of refreshes already...one more can't hurt. one item of
difference is I used 'pip install -e .'

On Thu, Jan 17, 2019, 11:30 AM Vincent(Yuan) Gao <[email protected]
wrote:

This might also be because your "mlagents-learn" command hasn't been
installed correctly. Have you done "pip install . " within your ml-agents
folder that contains setup.py? Has the ml-agents 0.6 python package been
installed successfully?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-455301406,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzEjW_CYmGTFFb8mhlclP2c3FU9L9ks5vEM9wgaJpZM4Xvmce
.

pip install -e . is the same, it just uses the local version of the code instead of the v0.6 one.

Voila !!!..I was able to connect to the 3Dball scene build...this is after
running pip install pypiwin32, of course. See below. One item which
surprised me was that I did not get the build results
I expected , i.e. the learning brains are in scene but not the build. I
must have missed something there?

(ml-agents) C:\Users\msi>mlagents-learn
C:\Users\msi\Downloads\ml-agents\config\trainer_config.yaml
--env=C:\Users\msi\Downloads\ml-agents\ml-agents\3DBall_Exp1 --train

                    โ–„โ–„โ–„โ–“โ–“โ–“โ–“
               โ•“โ–“โ–“โ–“โ–“โ–“โ–“โ–ˆโ–“โ–“โ–“โ–“โ–“
          ,โ–„โ–„โ–„mโ–€โ–€โ–€'  ,โ–“โ–“โ–“โ–€โ–“โ–“โ–„                           โ–“โ–“โ–“  โ–“โ–“โ–Œ
        โ–„โ–“โ–“โ–“โ–€'      โ–„โ–“โ–“โ–€  โ–“โ–“โ–“      โ–„โ–„     โ–„โ–„ ,โ–„โ–„ โ–„โ–„โ–„โ–„   ,โ–„โ–„ โ–„โ–“โ–“โ–Œโ–„ โ–„โ–„โ–„

,โ–„โ–„
โ–„โ–“โ–“โ–“โ–€ โ–„โ–“โ–“โ–€ โ–โ–“โ–“โ–Œ โ–“โ–“โ–Œ โ–โ–“โ–“ โ–โ–“โ–“โ–“โ–€โ–€โ–€โ–“โ–“โ–Œ โ–“โ–“โ–“ โ–€โ–“โ–“โ–Œโ–€ ^โ–“โ–“โ–Œ
โ•’โ–“โ–“โ–Œ
โ–„โ–“โ–“โ–“โ–“โ–“โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–“โ–“โ–“ โ–“โ–€ โ–“โ–“โ–Œ โ–โ–“โ–“ โ–โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–Œ โ–โ–“โ–“โ–„
โ–“โ–“โ–Œ
โ–€โ–“โ–“โ–“โ–“โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–“โ–“โ–„ โ–“โ–“ โ–“โ–“โ–Œ โ–โ–“โ–“ โ–โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–Œ
โ–โ–“โ–“โ–โ–“โ–“
^โ–ˆโ–“โ–“โ–“ โ–€โ–“โ–“โ–„ โ–โ–“โ–“โ–Œ โ–“โ–“โ–“โ–“โ–„โ–“โ–“โ–“โ–“ โ–โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–“ โ–“โ–“โ–“โ–„
โ–“โ–“โ–“โ–“ 'โ–€โ–“โ–“โ–“โ–„ ^โ–“โ–“โ–“ โ–“โ–“โ–“ โ””โ–€โ–€โ–€โ–€ โ–€โ–€ ^โ–€โ–€โ–€โ–€ โ–€โ–€ 'โ–€โ–€ โ–โ–“โ–“โ–Œ โ–€โ–€โ–€โ–€โ–“โ–„โ–„โ–„ โ–“โ–“โ–“โ–“โ–“โ–“, โ–“โ–“โ–“โ–“โ–€ โ–€โ–ˆโ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–Œ
ยฌ`โ–€โ–€โ–€โ–ˆโ–“

INFO:mlagents.trainers:{'--curriculum': 'None',
'--docker-target-name': 'None',
'--env': 'C:\Users\msi\Downloads\ml-agents\ml-agents\3DBall_Exp1',
'--help': False,
'--keep-checkpoints': '5',
'--lesson': '0',
'--load': False,
'--no-graphics': False,
'--num-runs': '1',
'--run-id': 'ppo',
'--save-freq': '50000',
'--seed': '-1',
'--slow': False,
'--train': True,
'--worker-id': '0',
'':
'C:\Users\msi\Downloads\ml-agents\config\trainer_config.yaml'}
INFO:mlagents.envs:
'Ball3DAcademy' started successfully!
Unity Academy name: Ball3DAcademy
Number of Brains: 1
Number of Training Brains : 0
Reset Parameters :

Unity brain name: 3DBallLearning
Number of Visual Observations (per agent): 0
Vector Observation space size (per agent): 8
Number of stacked Vector Observation: 1
Vector Action space type: continuous
Vector Action space size (per agent): [2]
Vector Action descriptions: ,
WARNING:mlagents.envs: No Learning Brains set to train found in the Unity
Environment. You will not be able to pass actions to your agent(s).

(ml-agents) C:\Users\msi>

On Thu, Jan 17, 2019 at 7:08 PM Vincent(Yuan) Gao notifications@github.com
wrote:

pip install -e . is the same, it just uses the local version of the code
instead of the v0.6 one.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-455412467,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzFS2vhaRcGDWnQTPa1Oqm4I8zuNBks5vETqfgaJpZM4Xvmce
.

I guess you didn't check the learning brain as external, or something else.

ah, yes you must be referring the control check box. will give it a go.
thanks for the help.

On Thu, Jan 17, 2019, 9:48 PM Vincent(Yuan) Gao <[email protected]
wrote:

I guess you didn't check the learning brain as external, or something else.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-455435047,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzE7S243QoKGZADxyl3hGJdBwyNqvks5vEWAUgaJpZM4Xvmce
.

I ran into this as well on Windows 10 64bit using ml-agents 0.6.
I would suggest adding the "pip install pypiwin32" command to Installation-Windows.md.

I'd second the motion.

On Mon, Jan 28, 2019, 3:14 AM Gregor Heinze <[email protected] wrote:

I ran into this as well on Windows 10 64bit using ml-agents 0.6.
I would suggest adding the "pip install pypiwin32" command to
Installation-Windows.md.

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1362#issuecomment-458089877,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AI_RzH8d7bJOXXHA7qu6GhpX8tcUCm_zks5vHtubgaJpZM4Xvmce
.

Also ran into the same error and the pip install pypiwin32 command fixed it for me. Feels good to finally have it running after uninstalling/reinstalling multiple times combing over the windows install guide profusely.

Thanks!

I will add the pypiwin32 dependency to the installation this or next week.

So I was getting:

ModuleNotFoundError: No module named 'win32api'

So I used the command pip install pypiwin32, which installed properly. When I try after installing, I get this error:

Import Error: DLL load failed: The specified module could not be found.

Did you follow the Windows installation guide and added the environment variables? (the folders are enough)
It's important to use the right python and tensorflow version.

@Cbunz I had the same issue
Here's what helped for me https://github.com/michaelgundlach/pyspeech/issues/23#issuecomment-280915608

Since this bug is fixed, I will close the issue. Feel free to open if you want to discuss more.

I had the same issue and it was fixed after running pip install pypiwin32

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tensorgpu picture tensorgpu  ยท  3Comments

Procuste34 picture Procuste34  ยท  3Comments

gerardsimons picture gerardsimons  ยท  3Comments

Rodnyy picture Rodnyy  ยท  3Comments

GeriBP picture GeriBP  ยท  3Comments