Hi,
I've stumbled upon this problem when trying to experiment with ML Agents. I have noticed that few other people got stuck on it as well but none of them has really replied here with a solution that would help in my case or replied with any solution at all.
ISSUE:
When I put "ENABLE_TENSORFLOW" into the Scripting Define Symbols fields my VS Code is getting red all over the "using Tensorflow;" in TFSharpInferenceEngine.cs
Screenshot:

My setup:
ML Agents: v0.6 - had the same problem on v0.5 as well
Unity version: 2018.3.0f2 (official) - had this issue on 2018.3.0f1 (beta) as well
TF : 1.12
Python: 3.6.7
VS Code: 1.3 with: C#, Debugger for Unity, Unity Tools plugins.
.NET Frameworks: (perhaps I have too many of them)?

Project Settings:

I installed TFSharpPlugin (by double clicking it. And I keep it in a different folder than Unity if it made any difference... i'm becoming paranoid.. :))
I confirmed to have this issue on both of my projects (started new, clean one as well)
Any suggestions would be greatly appreciated. Thanks!
As described here, make sure you installed that one:
https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackage
That could be the source of your issue.
As described here, make sure you installed that one:
https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackageThat could be the source of your issue.
Thanks for the reply, but I have installed TFSharpPlugin. I described it here in my initial post:
"I installed TFSharpPlugin (by double clicking it. And I keep it in a different folder than Unity if it made any difference... i'm becoming paranoid.. :))"
Just wanted to make sure we both installed the same ;)
Also, I can confirm it doesn't make any difference to keep the
.unitypackage inside or outside of the project folder.
One difference I can see with my (working) project is the API compatibility
level in Player Settings. Mine is set to ".Net Standard 2.0" (while yours
seems to be set to ".Net 4")
On Wed, Dec 19, 2018, 8:54 PM oddEventHorizon <[email protected]
wrote:
As described here
https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Using-TensorFlow-Sharp-in-Unity.md,
make sure you installed that one:
https://s3.amazonaws.com/unity-ml-agents/0.5/TFSharpPlugin.unitypackageThat could be the source of your issue.
Thanks for the reply, but I have installed TFSharpPlugin. I described it
here in my initial post:"I installed TFSharpPlugin (by double clicking it. And I keep it in a
different folder than Unity if it made any difference... i'm becoming
paranoid.. :))"—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Unity-Technologies/ml-agents/issues/1511#issuecomment-448871403,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAI75RUAEIVq1PthbAK_wiaHhDlO7CYNks5u6xgLgaJpZM4ZbYcs
.
I had this issue migrating from 0.5 to 0.6, and fixed it by reimporting TFsharp (on Ubuntu import package -> custom package) and it's located in Assets/Plugin
Where is your tfsharp imported ?
@13Flo - thanks for noticing it, however it did not fix my issue. I changed it to .NET Standrad 2.0 regardless as I'm not sure why it was changed.
@louis030195 - thank you for your reply.
The only reference of TFSharpPlugin I found was in here:

I double clicked the TFSharpPlugin.unitypackage file - assumed it will target itself correctly.
Hi @oddEventHorizon
Do you get errors in the Unity Editor, or just in VS Code?
Hi @oddEventHorizon
Do you get errors in the Unity Editor, or just in VS Code?
Hi.
No. Zero errors in Unity. I can even hit play button in one of the examples you've provided and game starts to simulate. However ML agents features are not working.
I have been trying desperately to find what broke it and potential workaround that I've came up with this.
When mentioned issue occurs in VS Code about tensorflow namespace or type not found, I open my Visual Studio 2017 Community. I open my project solution properties and I change:
Target Framework from: .NET Framework 4.5 to: .NET Framework 4.6.1
Then I go back to VS Code and all the compilation errors are gone. However If I close VS Code (that had no issues at the moment of closing) and I reopen it with Unity->Assets->Open C# Project - the problem occurs again.
It seems as if Unity was forcing .NET Framework 4.5 for some reason.
However as much as I'm happy that I have found a workaround I doubt it's a proper solution and I assume there is be some mistake that I'm making.
That could be a good occasion to switch to Jetbrains Rider... ;)
@13Flo : yeah, but the price :)
Update:
I have noticed that until I change .NET Framework via Visual Studio Community 2017 I'm getting this printed out in the OmniSharp Log output window:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): Error: The primary reference "TensorFlowSharp" could not be resolved because it was built against the ".NETFramework,Version=v4.6.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): Error: The primary reference "System.Interactive.Async" could not be resolved because it was built against the ".NETFramework,Version=v4.6" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.5".
I also almost certain that this issue was not occuring on Unity 2017 where I was able to specifically pick which .NET Framework 4.6 from the Scripting Runtime Version field in the Project Settings. In Unity 2018 you can only specify .NET Framework 4.x (equivalent). Maybe it's hardcoded to 4.5 somewhere?
@awjuliani
We have replaced TF# with our internal inference solution as of v0.7. Closing this issue for now. Please feel free to re-open if you deem it necessary.
@awjuliani I am using the v0.7 ml-agent, and unity 2018.3.11. Still facing the same issue.

Step to reproduce the setup

Hi @weiweitoo , since we got rid of TensorflowSharp, please remove the ENABLE_TENSORFLOW symbol, and it should be working.
@xiaomaogy Cool. It works perfectly. Thanks!
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.
Most helpful comment
Hi @weiweitoo , since we got rid of TensorflowSharp, please remove the ENABLE_TENSORFLOW symbol, and it should be working.