2017-11-24 23 views
0

すでにPython 3をインストールした場合、Python 2.7コードを使用する最も良い方法は何ですか?Python 3.5でPython 2.7スクリプトを実行する方法/ 2.7 Pythonスクリプトを実行するのに最適なオプション

私はPythonで新しく、ほとんどのビデオチュートリアルやWebトピックではPython 3を使用する方が良いと言われています。 しかし、2.7のPython用コードを実行しようとすると3、ときどき動作しません。 良いオプションは何ですか?私のPC上でPython 2と3の両方を使用する。 Python 3コードだけを探すこともできます。またはPython 2.7のコードを何とか変更しますか? これらのエラーです:あなたは2つのオプションがありますので、

IPython 6.1.0 -- An enhanced Interactive Python. 

runfile('C:/Users/G/Desktop/image_recognition/new_test/GemData.py', wdir='C:/Users/G/Desktop/image_recognition/new_test') 

Traceback (most recent call last): 

    File "C:\ProgramData\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code 
    exec(code_obj, self.user_global_ns, self.user_ns) 

    File "<ipython-input-1-02441e959cce>", line 1, in <module> 
    runfile('C:/Users/G/Desktop/image_recognition/new_test/GemData.py', wdir='C:/Users/G/Desktop/image_recognition/new_test') 

    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile 
    execfile(filename, namespace) 

    File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile 
    exec(compile(f.read(), filename, 'exec'), namespace) 

    File "C:/Users/G/Desktop/image_recognition/new_test/GemData.py", line 19 
    print "error: image not read from file \n\n"  # print error message to std out 
              ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print "error: image not read from file \n\n"  # print error message to std out)? 
+0

virtualenvを使用して、異なるマシンで異なるバージョンのPythonを実行することができます –

答えて

関連する問題