Tweeted twitter.com/StackMma/status/886725763822624768
2 added 2 characters in body
source | link

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script.

I have a script my_script.py which just contains print(Hello'Hello, World!').

If from within Mathematica I pass

pythonOutput = Import["!python my_script.py", "String"]

I get the expected

Hello, world!

However, I am on Mac OS where the default installation of python is python 2.7 and so if I want to run my code in python 3.x in the terminal I would have to say

python3 my_script.py (which works fine)

However, when I modify my Mathematica code to say

pythonOutput = Import["!python3 my_script.py", "String"]

I get no output! Does anyone know why this might be the case? The command python3 my_script.py works perfectly fine from the terminal but not within an Import statement.


I have also tried every suggestion from this question and none of them work with the python3 command.

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script.

I have a script my_script.py which just contains print(Hello, World!).

If from within Mathematica I pass

pythonOutput = Import["!python my_script.py", "String"]

I get the expected

Hello, world!

However, I am on Mac OS where the default installation of python is python 2.7 and so if I want to run my code in python 3.x in the terminal I would have to say

python3 my_script.py (which works fine)

However, when I modify my Mathematica code to say

pythonOutput = Import["!python3 my_script.py", "String"]

I get no output! Does anyone know why this might be the case? The command python3 my_script.py works perfectly fine from the terminal but not within an Import statement.


I have also tried every suggestion from this question and none of them work with the python3 command.

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script.

I have a script my_script.py which just contains print('Hello, World!').

If from within Mathematica I pass

pythonOutput = Import["!python my_script.py", "String"]

I get the expected

Hello, world!

However, I am on Mac OS where the default installation of python is python 2.7 and so if I want to run my code in python 3.x in the terminal I would have to say

python3 my_script.py (which works fine)

However, when I modify my Mathematica code to say

pythonOutput = Import["!python3 my_script.py", "String"]

I get no output! Does anyone know why this might be the case? The command python3 my_script.py works perfectly fine from the terminal but not within an Import statement.


I have also tried every suggestion from this question and none of them work with the python3 command.

1
source | link

Problem calling Python scripts from Mathematica

so I'm running into a strange problem using Import[] to import the output of a python 3.6 script.

I have a script my_script.py which just contains print(Hello, World!).

If from within Mathematica I pass

pythonOutput = Import["!python my_script.py", "String"]

I get the expected

Hello, world!

However, I am on Mac OS where the default installation of python is python 2.7 and so if I want to run my code in python 3.x in the terminal I would have to say

python3 my_script.py (which works fine)

However, when I modify my Mathematica code to say

pythonOutput = Import["!python3 my_script.py", "String"]

I get no output! Does anyone know why this might be the case? The command python3 my_script.py works perfectly fine from the terminal but not within an Import statement.


I have also tried every suggestion from this question and none of them work with the python3 command.