Coderunner uses old 2.71 version of Python instead of 3.2 on OSX 10.7.5

感情迁移 提交于 2020-12-25 03:50:32

问题


I am trying to use the newer version of Python but when I type:

    import sys
    print sys.version_info

I get back:

    sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)

In the terminal when I type python I get:

Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin

When I type python3 I get:

Python 3.3.2 (v3.3.2:d047928ae3f6, May 13 2013, 13:52:24) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

As you see, I have installed Python 3.3 but no matter what I do I can't seem to actually use it in CodeRunner.


回答1:


CodeRunner->Preferences->Languages->Run Command

edit "python $filename" to "python3 $filename"




回答2:


For the latest vscode you need to go to settings (shift+command+p) and override python interpreter value.




回答3:


in new versions in setting.json file just add:

"code-runner.

*note that (")

it predicts its continue or you can press ctrl+space and select "code-runner. "code-runner.executorMap" it show all of run commands easyly change

"python": "python -u",

to

"python": "python3 -u",

to change your intellisense for error handling in python3: then press ctrl+shift+P select python:select interpreter and select python 3.x.x




回答4:


Try changing Python's "run command" in the preferences to:

python3 $filename;



回答5:


Use Command+, to open the Preferences, and then make sure the Languages of Python3 have this:

Right Run Command

BTW, use which python3 to make sure the path is /usr/local/bin/python3 instead of /usr/bin/python3 to ensure safety




回答6:


Crate a python file and get current sysinfo

import sys
print(sys.version_info)

Need to change to python3?

  1. open your vscode settings file
    1.1 mac: command+shift+p
    1.2. search for openSettingsJson
  2. locate the python attribute in the json object
  3. change the value to python3
  4. validate results by running the aforementioned file
  5. profit


来源:https://stackoverflow.com/questions/19797616/coderunner-uses-old-2-71-version-of-python-instead-of-3-2-on-osx-10-7-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!