Sublime 3: Strange output using build system for Python3

divide_by_zero

I'm on OS X and I'm trying to get python3 working in sublime. I installed python3 via homebrew and I installed numpy for both python and python3 using pip. In order to be able to build python3 I added the following build file for sublime:

{
    "path": "/usr/local/Cellar/python3/3.4.2_1/bin",
    "cmd": ["python3", "-u", "$file"],
    "env":{},
    "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

Finally I'm trying out the build system on the following test file:

#test.py
import numpy

def square(x):
    return x * x

if __name__ == '__main__':
    print("test: square(42) ==", square(42))

If I build this with the build system set to python (which uses the OS X default version of python 2.7.8) then I get the following (correct) output when I build in sublime:

('test: square(42) ==', 1764)
[Finished in 0.1s]

However, if I set my build system to build with python3 I get the following strange results when I build in sublime:

sh: sysctl: command not found
sh: grep: command not found
sh: sw_vers: command not found
sh: grep: command not found
test: square(42) == 1764
[Finished in 0.1s]

I still get the correct output but also get a bunch of command not found. What's even stranger, if I save this script and run it directly from the terminal using python test.py for python 2.7.8 or using python3 test.py for python 3 I get the correct output in the terminal. Additionally, if I remove import numpy from test.py I no longer get any of the command not found errors in my sublime output.

This problem seems to only show up in sublime using python3 with the above build file and only when I'm trying to import a library installed with pip. If I change the above import in test.py to sys then it will build in sublime without any error messages.

Mephistopheles

I think I have an answer for you.

Your path variable

    "path": "/usr/local/Cellar/python3/3.4.2_1/bin",

needs to append to the existing $PATH. Simply replacing that line in your build file with

    "path": "$PATH:/usr/local/Cellar/python3/3.4.2_1/bin",

fixed it for me.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

PHP build system error in sublime text 3

分類Dev

Sublime 3 Markdown Build System via Pandoc

分類Dev

Sublime Text3とsublime-grunt-build

分類Dev

build file location for sublime version 3

分類Dev

My Pressure Sensor Wont Output the Full Range of Values, Using a Raspberry Pi 3 and Python3

分類Dev

Sublime text 2 build system

分類Dev

Strange output in Python 3.6

分類Dev

How to split the string using python3

分類Dev

Upgrading Sublime text 3

分類Dev

Get the output of .exe file in Python3 on Windows

分類Dev

strange output when using with vector iterato

分類Dev

Getting Desktop path with different system languages in python3

分類Dev

Sublime Text 2, disable Build output panel/Console automatic scrolling

分類Dev

Sublime 2 REPLMacでPython3を実行する方法

分類Dev

Sublime Text strange behaviour

分類Dev

~1 and ~0 giving strange results in python 3

分類Dev

Sass support for sublime text 3

分類Dev

Sublime Text 3 dpkg error

分類Dev

Strange Output from Python urllib2

分類Dev

Strange CSS3 Button

分類Dev

Python3 Unittest: How to compare with MagicMocks Using Operators

分類Dev

Sublime Text 3のJavac.sublime-buildファイルはどこにありますか?(ウィンドウズ)

分類Dev

SublimeはPython3を使用し、SublimeREPLはPython2.7を使用します。え?

分類Dev

Golang: Multidimensional array using slice of slice strategy resulting in strange output

分類Dev

Sublime Text 3 'subl' command still linked to Sublime Text 2

分類Dev

Python3 Pyserial

分類Dev

Python3 UnicodeEncodingError

分類Dev

What is the difference between using pip3 vs pip when running python3 virtualenv

分類Dev

Conditionally using the .exe extension with the Shake build system

Related 関連記事

  1. 1

    PHP build system error in sublime text 3

  2. 2

    Sublime 3 Markdown Build System via Pandoc

  3. 3

    Sublime Text3とsublime-grunt-build

  4. 4

    build file location for sublime version 3

  5. 5

    My Pressure Sensor Wont Output the Full Range of Values, Using a Raspberry Pi 3 and Python3

  6. 6

    Sublime text 2 build system

  7. 7

    Strange output in Python 3.6

  8. 8

    How to split the string using python3

  9. 9

    Upgrading Sublime text 3

  10. 10

    Get the output of .exe file in Python3 on Windows

  11. 11

    strange output when using with vector iterato

  12. 12

    Getting Desktop path with different system languages in python3

  13. 13

    Sublime Text 2, disable Build output panel/Console automatic scrolling

  14. 14

    Sublime 2 REPLMacでPython3を実行する方法

  15. 15

    Sublime Text strange behaviour

  16. 16

    ~1 and ~0 giving strange results in python 3

  17. 17

    Sass support for sublime text 3

  18. 18

    Sublime Text 3 dpkg error

  19. 19

    Strange Output from Python urllib2

  20. 20

    Strange CSS3 Button

  21. 21

    Python3 Unittest: How to compare with MagicMocks Using Operators

  22. 22

    Sublime Text 3のJavac.sublime-buildファイルはどこにありますか?(ウィンドウズ)

  23. 23

    SublimeはPython3を使用し、SublimeREPLはPython2.7を使用します。え?

  24. 24

    Golang: Multidimensional array using slice of slice strategy resulting in strange output

  25. 25

    Sublime Text 3 'subl' command still linked to Sublime Text 2

  26. 26

    Python3 Pyserial

  27. 27

    Python3 UnicodeEncodingError

  28. 28

    What is the difference between using pip3 vs pip when running python3 virtualenv

  29. 29

    Conditionally using the .exe extension with the Shake build system

ホットタグ

アーカイブ