質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

解決済

1回答

2748閲覧

IronPythonでthreadingが使えない

Elect

総合スコア17

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2016/10/24 23:06

###前提・実現したいこと
IronPythonでPython標準モジュールのthreadingをimportしたいです。
IronPythonはUnityでアプリ開発をするために導入しました。
###発生している問題・エラーメッセージ
IronPython/Lib以下の他の標準モジュールに関してはimoportできるのですが、threadingだけはimportできず、以下のようなエラーが出てしまいます。

SyntaxErrorException: unexpected token ',' IronPython.Runtime.ThrowingErrorSink.Add (Microsoft.Scripting.SourceUnit sourceUnit, System.String message, SourceSpan span, Int32 errorCode, Severity severity) IronPython.Compiler.Parser.ReportSyntaxError (Int32 start, Int32 end, System.String message, Int32 errorCode) IronPython.Compiler.Parser.ReportSyntaxError (IronPython.Compiler.Token t, IndexSpan span, Int32 errorCode, Boolean allowIncomplete) IronPython.Compiler.Parser.ReportSyntaxError (TokenWithSpan t, Int32 errorCode) IronPython.Compiler.Parser.ReportSyntaxError (TokenWithSpan t) IronPython.Compiler.Parser.ReadName () IronPython.Compiler.Parser.ParseParameterName (System.Collections.Generic.HashSet`1 names, ParameterKind kind) IronPython.Compiler.Parser.ParseVarArgsList (TokenKind terminator) IronPython.Compiler.Parser.ParseFuncDef () IronPython.Compiler.Parser.ParseStmt () IronPython.Compiler.Parser.ParseSuite () IronPython.Compiler.Parser.ParseClassOrFuncBody () IronPython.Compiler.Parser.ParseClassDef () IronPython.Compiler.Parser.ParseStmt () IronPython.Compiler.Parser.ParseFileWorker (Boolean makeModule, Boolean returnValue) IronPython.Compiler.Parser.ParseFile (Boolean makeModule, Boolean returnValue) IronPython.Runtime.PythonContext.ParseAndBindAst (Microsoft.Scripting.Runtime.CompilerContext context) IronPython.Runtime.PythonContext.CompilePythonCode (Microsoft.Scripting.SourceUnit sourceUnit, Microsoft.Scripting.CompilerOptions options, Microsoft.Scripting.ErrorSink errorSink) IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, ModuleOptions options, IronPython.Compiler.CompilationMode mode) IronPython.Runtime.PythonContext.GetScriptCode (Microsoft.Scripting.SourceUnit sourceCode, System.String moduleName, ModuleOptions options) IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, ModuleOptions options, Microsoft.Scripting.ScriptCode& scriptCode) IronPython.Runtime.PythonContext.CompileModule (System.String fileName, System.String moduleName, Microsoft.Scripting.SourceUnit sourceCode, ModuleOptions options) IronPython.Runtime.Importer.LoadFromSourceUnit (IronPython.Runtime.CodeContext context, Microsoft.Scripting.SourceUnit sourceCode, System.String name, System.String path) IronPython.Runtime.Importer.LoadModuleFromSource (IronPython.Runtime.CodeContext context, System.String name, System.String path) IronPython.Runtime.Importer.LoadFromDisk (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, System.String str) IronPython.Runtime.Importer.ImportFromPathHook (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path, System.Func`5 defaultLoader) IronPython.Runtime.Importer.ImportFromPath (IronPython.Runtime.CodeContext context, System.String name, System.String fullName, IronPython.Runtime.List path) IronPython.Runtime.Importer.ImportTopAbsolute (IronPython.Runtime.CodeContext context, System.String name) IronPython.Runtime.Importer.ImportModule (IronPython.Runtime.CodeContext context, System.Object globals, System.String modName, Boolean bottom, Int32 level) IronPython.Modules.Builtin.__import__ (IronPython.Runtime.CodeContext context, System.String name, System.Object globals, System.Object locals, System.Object fromlist, Int32 level) Microsoft.Scripting.Interpreter.FuncCallInstruction`7[IronPython.Runtime.CodeContext,System.String,System.Object,System.Object,System.Object,System.Int32,System.Object].Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame) Microsoft.Scripting.Interpreter.Interpreter.Run (Microsoft.Scripting.Interpreter.InterpretedFrame frame)

###該当のソースコード

Python

1import clr 2clr.AddReferenceByPartialName('UnityEngine') 3import UnityEngine 4 5import sys 6sys.path.append(UnityEngine.Application.dataPath + '/../../IronPython/Lib') 7 8import threading 9print(threading.__file__)

###試したこと
他の物をimportしてみたところ(numbersをimportしてみました)、こちらは正しく読み込まれたらしく、
C:\Users......\IronPython\Lib\numbers.py
と出力されました。
###補足情報(言語/FW/ツール等のバージョンなど)
Python3.5を使っています

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

nagaetty

2016/10/25 01:57

Windows環境でanacond3 でimport threading とprint(threading.__file__)正常動作しておりますので、環境差分かと思います。再インストールが可能であればそちらのほうが良いかと思います。
Elect

2016/10/25 15:56

再インストールを試したところ、少なくとも前回とは違い正しい出力を得られました!ありがとうございます!
nagaetty

2016/10/26 01:56

よかったです!v(^_^)V
guest

回答1

0

ベストアンサー

既に、解決したようですが、
Windows環境でanacond3 でimport threading とprint(threading.file)正常動作しておりますので、環境差分かと思います。再インストールが可能であればそちらのほうが良いかと思います。

投稿2016/10/26 10:27

nagaetty

総合スコア1106

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問