ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 16 Mar 2022 16:27:09 +0100Where is numpy, scipy, etc. for Python 3.7 ??https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/I have Sagemath installed on my Mac with Python versions 2.7 and 3.7 in the package.
I'm running sage/python as scripts. For Python 2.7 I use the shebang,
#!/Applications/SageMath/local/bin/python2.7
And the code executes correctly including an "import numpy as NP" line.
When I switch to Python 3.7 I use the shebang
#!/Applications/SageMath/local/bin/python3.7
This works for 2to3.py and importing python libs like subprocess and sys, but when I add
import numpy as NP
I get the error,
File "/Users/louispecora/Code_py/PyConversion2to3/testfordivops/DIVchk2to3.2.7.py", line 4, in <module>
import numpy as NP
ModuleNotFoundError: No module named 'numpy'
I see numpy folder in the pkgs/ at the path
/Applications/SageMath/build/pkgs/numpy
Anyone have an idea why 3.7 can't find numpy, scipy, etc., but 2.7 can?
Thanks for any help.
-- Lou Pecora
Tue, 15 Mar 2022 19:45:26 +0100https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/Comment by LouP for <p>I have Sagemath installed on my Mac with Python versions 2.7 and 3.7 in the package. <br>
I'm running sage/python as scripts. For Python 2.7 I use the shebang,</p>
<p>#!/Applications/SageMath/local/bin/python2.7</p>
<p>And the code executes correctly including an "import numpy as NP" line.</p>
<p>When I switch to Python 3.7 I use the shebang</p>
<p>#!/Applications/SageMath/local/bin/python3.7</p>
<p>This works for 2to3.py and importing python libs like subprocess and sys, but when I add </p>
<p>import numpy as NP</p>
<p>I get the error,</p>
<p>File "/Users/louispecora/Code_py/PyConversion2to3/testfordivops/DIVchk2to3.2.7.py", line 4, in <module>
import numpy as NP
ModuleNotFoundError: No module named 'numpy'</p>
<p>I see numpy folder in the pkgs/ at the path</p>
<p>/Applications/SageMath/build/pkgs/numpy</p>
<p>Anyone have an idea why 3.7 can't find numpy, scipy, etc., but 2.7 can?</p>
<p>Thanks for any help.</p>
<p>-- Lou Pecora</p>
https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?comment=61531#post-id-61531Hi, Mr. Palmieri. Yes, I am using Mac OS X. (see my answer to why no numpy was in my older Sage package in this post). However, I updated my Sage package: After posting my question I downloaded sage-9.4-OSX_11.2.3-x86_64.tar.bz2 from Sage Downloads, extracted, and put it in my Applications folder. This had numpy, etc. But when I try to run my script by using the shebang to point to Python3.9 in the Sage 9.4 package, I get an error stating that
dyld: Library not loaded: /Users/buildbot-sage/slave/binary_pkg/build/source/SageMath/jc4b6yulaujayb9sr94ia88eourzeqip0oidmas3/local/lib/libpython3.9.dylib
I have no idea what this means. Previous scripts using Python2.7 (when it was in Sage) ran without this type of error.
Please let me know if you understand this.
Thank you. -- LouWed, 16 Mar 2022 16:27:09 +0100https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?comment=61531#post-id-61531Comment by John Palmieri for <p>I have Sagemath installed on my Mac with Python versions 2.7 and 3.7 in the package. <br>
I'm running sage/python as scripts. For Python 2.7 I use the shebang,</p>
<p>#!/Applications/SageMath/local/bin/python2.7</p>
<p>And the code executes correctly including an "import numpy as NP" line.</p>
<p>When I switch to Python 3.7 I use the shebang</p>
<p>#!/Applications/SageMath/local/bin/python3.7</p>
<p>This works for 2to3.py and importing python libs like subprocess and sys, but when I add </p>
<p>import numpy as NP</p>
<p>I get the error,</p>
<p>File "/Users/louispecora/Code_py/PyConversion2to3/testfordivops/DIVchk2to3.2.7.py", line 4, in <module>
import numpy as NP
ModuleNotFoundError: No module named 'numpy'</p>
<p>I see numpy folder in the pkgs/ at the path</p>
<p>/Applications/SageMath/build/pkgs/numpy</p>
<p>Anyone have an idea why 3.7 can't find numpy, scipy, etc., but 2.7 can?</p>
<p>Thanks for any help.</p>
<p>-- Lou Pecora</p>
https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?comment=61520#post-id-61520It looks like you're using Mac OS X. Is that correct? What version of Sage are you using? Recent versions of Sage should not include any version of Python 2 at all, just Python 3. Did you download a binary file or did you build Sage yourself?Tue, 15 Mar 2022 23:57:57 +0100https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?comment=61520#post-id-61520Answer by LouP for <p>I have Sagemath installed on my Mac with Python versions 2.7 and 3.7 in the package. <br>
I'm running sage/python as scripts. For Python 2.7 I use the shebang,</p>
<p>#!/Applications/SageMath/local/bin/python2.7</p>
<p>And the code executes correctly including an "import numpy as NP" line.</p>
<p>When I switch to Python 3.7 I use the shebang</p>
<p>#!/Applications/SageMath/local/bin/python3.7</p>
<p>This works for 2to3.py and importing python libs like subprocess and sys, but when I add </p>
<p>import numpy as NP</p>
<p>I get the error,</p>
<p>File "/Users/louispecora/Code_py/PyConversion2to3/testfordivops/DIVchk2to3.2.7.py", line 4, in <module>
import numpy as NP
ModuleNotFoundError: No module named 'numpy'</p>
<p>I see numpy folder in the pkgs/ at the path</p>
<p>/Applications/SageMath/build/pkgs/numpy</p>
<p>Anyone have an idea why 3.7 can't find numpy, scipy, etc., but 2.7 can?</p>
<p>Thanks for any help.</p>
<p>-- Lou Pecora</p>
https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?answer=61530#post-id-61530I've found the answer to my question about not importing numpy or scipy. A Python 3.7 version of either library did not exist at the time 3.7 was released. I downloaded Sage 9.4 which has Python 3.9 and numpy and scipy for that version of Python.
However, when I try to run the script I have another problem with a binary_pkg that can't be found to run Python 3.9 in the Sage package. I will ask about this in another post on this forum. Thanks.Wed, 16 Mar 2022 16:15:46 +0100https://ask.sagemath.org/question/61518/where-is-numpy-scipy-etc-for-python-37/?answer=61530#post-id-61530