Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.19k stars 4.16k forks source link

E0611:No name 'python' in module 'tensorflow' #1411

Closed ManaAura closed 6 years ago

ManaAura commented 6 years ago

Hello all,

Problem description I have followed the guide on ml-agent's installation guide (windows via Anaconda):

  1. conda create -n ml-agents python=3.6
  2. activate ml-agents
  3. pip install tensorflow==1.7.1
  4. cd to the mlagent folder and "pip install ."

However, when I opened trainer_controller.py in vscode, I keep getting the following error: E0611:No name 'python' in module 'tensorflow' because of this code: from tensorflow.python.tools import freeze_graph

Observations

  1. import tensorflow as tf works fine
  2. tensorflow.python.tools doesnt work
  3. I don't understand why a sub_module of tensorflow couldn't get imported

image

Please Help Me~

zongjingyao commented 6 years ago

It might be a bug in pylint. This page could help. https://medium.com/@haominnn/how-to-deal-with-python-not-finding-tensor-flow-module-under-anaconda-3aefa8ffae11

vincentpierre commented 6 years ago

Hi @ManaAura , does the training work when calling mlagents-learn from the console ? You should be able to run the training without having to edit any Python code at all. If the training does not start, could you post the error here ? @zongjingyao Thank you for your message.

ManaAura commented 6 years ago

Thank you all, mlagents-learn works from the console! :) .

asciidiego commented 5 years ago

It might be a bug in pylint. This page could help. https://medium.com/@haominnn/how-to-deal-with-python-not-finding-tensor-flow-module-under-anaconda-3aefa8ffae11

Helped a lot! Just Ctrl+Shift+P and searched for linter. And changed to PEP8. All good now! :smile:

Flamefire commented 5 years ago

It might be a bug in pylint. This page could help. https://medium.com/@haominnn/how-to-deal-with-python-not-finding-tensor-flow-module-under-anaconda-3aefa8ffae11

This is NOT a solution. Simply disabling a tool because of an error doesn't fix the error.

Now to the bug:

Why: Then TF package is just a proxy that redirects stuff to the internal package called tensorflow_core as can be verified by importing that. The problem: You are not allowed to do that as it is an internal package.

Solution: Tell pylint about this. This can be done via pylint plugins although I'm currently not aware if there are already some that do that.

Note: Yes everything does work even though there are linter errors. You may ignore them or switch to another linter as described in the link. But it would be great if someone finds a solution for pylint as that is way more powerful than pep8, which is mostly a style-checker.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.