ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 27 May 2019 16:53:04 -0500SAGE 8.1, cannot import python modules from notebookhttp://ask.sagemath.org/question/41315/sage-81-cannot-import-python-modules-from-notebook/I'm running into trouble trying to setup SAGE 8.1.
What happened is the following.
I'm working in Linux Ubuntu 16.4. I installed SAGE 7.5.1 from command-line. Then I installed SAGE 8.1 from pre-built binaries. I deleted the old sage version and now when I run the command sage, it tries to find SAGE 7.5.1 and fails.
I already ran:
ln -s /SageMath8.1/sage /usr/local/bin/sage
And nothing changed. Even though I can run SAGE 8.1 with:
/SageMath8.1/.sage
But once there I cannot import python modules:
>>> import pandas as pd
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-17-af55e7023913> in <module>()
----> 1 import pandas as pd
ImportError: No module named pandas
I guess there's a problem with paths, but I don't know how to solve it.
Any help?
daranhaWed, 28 Feb 2018 13:34:14 -0600http://ask.sagemath.org/question/41315/Error building python 2 with sagehttp://ask.sagemath.org/question/46688/error-building-python-2-with-sage/When I run the command `sage -f python2` the error:
[python2-2.7.15.p0] Copying package files from temporary location /Applications/SageMath-8.7.app/Contents/Resources/sage/local/var/tmp/sage/build/python2-2.7.15.p0/inst to /Applications/SageMath-8.7.app/Contents/Resources/sage/local
[python2-2.7.15.p0] cp: symlink: python-2.7.pc: File exists
[python2-2.7.15.p0] cp: symlink: python2.pc: File exists
[python2-2.7.15.p0] ************************************************************************
[python2-2.7.15.p0] Error copying files for python2-2.7.15.p0.
[python2-2.7.15.p0] ************************************************************************
[python2-2.7.15.p0] Please email sage-devel
[python2-2.7.15.p0] explaining the problem and including the log file
[python2-2.7.15.p0] /Applications/SageMath-8.7.app/Contents/Resources/sage/logs/pkgs/python2-2.7.15.p0.log
[python2-2.7.15.p0] Describe your computer, operating system, etc.
[python2-2.7.15.p0] ************************************************************************
make[1]: *** [/Applications/SageMath-8.7.app/Contents/Resources/sage/local/var/lib/sage/installed/python2-2.7.15.p0] Error 1
real 2m38.586s
user 1m47.897s
sys 0m39.865s
***************************************************************
Error building Sage.
The following package(s) may have failed to build (not necessarily during this run of 'make python2'):
* package: python2-2.7.15.p0
log file: /Applications/SageMath-8.7.app/Contents/Resources/sage/logs/pkgs/python2-2.7.15.p0.log
build directory: /Applications/SageMath-8.7.app/Contents/Resources/sage/local/var/tmp/sage/build/python2-2.7.15.p0
The build directory may contain configuration files and other potentially
helpful information. WARNING: if you now run 'make' again, the build
directory will, by default, be deleted. Set the environment variable
SAGE_KEEP_BUILT_SPKGS to 'yes' to prevent this.
make: *** [python2] Error 1
It looks like there is an error with a symlink - cp: symlink: python-2.7.pc: File existsdavidcorbinMon, 27 May 2019 16:53:04 -0500http://ask.sagemath.org/question/46688/Error occurs Compiling with sage “SystemError: new style getargs format but argument is not a tuple”http://ask.sagemath.org/question/43411/error-occurs-compiling-with-sage-systemerror-new-style-getargs-format-but-argument-is-not-a-tuple/ When the following codes are compiling with python everything is good, there is no error, but when I compile with sage it occurs the error : "SystemError: new style getargs format but argument is not a tuple"
Here is my code
from PIL import Image
file=Image.open('/home/mks/Desktop/Shamir_VSIS/si.jpeg')
file2=file.convert("L")
pix = file2.load()
colsize,rowsize=file2.size
for i in range(rowsize):
for j in range(colsize):
if pix[j,i]>250:
pix[j,i]=250
file2.save('/home/mks/Desktop/Shamir_VSIS/si.pgm')
How can I fix this issue?math.mks@yandex.comSat, 18 Aug 2018 01:35:18 -0500http://ask.sagemath.org/question/43411/How to fix "IOError: decoder jpeg not available"http://ask.sagemath.org/question/43298/how-to-fix-ioerror-decoder-jpeg-not-available/I have stuck when I compile these code in SageNotebook:
from PIL import Image
img=Image.open("/home/pmath/Music/im1.jpg")
img2=img.convert("L")
img2.save("/home/pmath/Music/secretimage.pgm")
img=Image.open("/home/pmath/Music/secretimage.pgm")
pix=img.load()
print pix
The following errors occur :
Traceback (click to the left of this block for traceback)
...
IOError: decoder jpeg not available
But when I compile these codes with python on the same OS(ubuntu32bit 16.04) it works well. The problems occur only on Sage. How can i fix this issue?math.mks@yandex.comThu, 09 Aug 2018 06:08:18 -0500http://ask.sagemath.org/question/43298/Differences between Python2 Sagemath and Python3 Sagemath?http://ask.sagemath.org/question/42932/differences-between-python2-sagemath-and-python3-sagemath/ With sagemath looking to move away from python2 in 2020 and as a new user of sagemath, I wanted to know what the differences are between Python2 Sagemath and Python3 Sagemath?
At the moment sagemath is not fully compatible with python3 and I have been told to expect problems. I want to know how serious these problems are and how frequent they are. I would then be able to know if using python3 sagemath is worth the trouble.number123Wed, 11 Jul 2018 14:35:20 -0500http://ask.sagemath.org/question/42932/Python 3 print in Sagehttp://ask.sagemath.org/question/38805/python-3-print-in-sage/ This is a minor issue, but I've long migrated all my Python scripts to Py3, so I'm trying to write in Sage in the most Py3-compliant way possible, since we'll have Py3 support in a not-so-distant future according to the FAQs (frankly I'm a bit surprised that Py3 support haven't already happened, but, oh well).
Anyway, because of that I put `from __future__ import print_function, division` in the very first line of my `init.sage`.
If I type things interactively in the prompt, it works as it's supposed to:
sage: print('C_r' ,6)
C_r 6
However, if I run a script with `load('my_script.sage')` it prints things as if I was using Py2.
('C_r', 6)
Am I loading my scripts wrong? How can I get it to work for scripts too?
Cheers.tomchoTue, 12 Sep 2017 11:40:04 -0500http://ask.sagemath.org/question/38805/Suppress automatically generated Python files when running Sage scripthttp://ask.sagemath.org/question/38383/suppress-automatically-generated-python-files-when-running-sage-script/ Hello,
I'm curious if it is possible to stop Sage from automatically generating corresponding Python files. For instance, if I run a sage script `test.sage`, then after running `sage test.sage`, I'll get an automatically generated file called `test.sage.py`. Is there any way to suppress the generation of this file? I tried to take a look in the documentation, but I couldn't find anything.
Thanks again! Vincent RussoMon, 24 Jul 2017 13:44:17 -0500http://ask.sagemath.org/question/38383/Is the sage --python exactly the same Python as it claims to be?http://ask.sagemath.org/question/32322/is-the-sage-python-exactly-the-same-python-as-it-claims-to-be/ Is the sage --python exactly the same Python as it claims to be?
I.e.
Can it be used to compile any Python program that's compatible with the libraries that it finds and the particular Python version?mavaviljSat, 23 Jan 2016 11:27:13 -0600http://ask.sagemath.org/question/32322/Trying to find phase and group delay of transfer functionshttp://ask.sagemath.org/question/29386/trying-to-find-phase-and-group-delay-of-transfer-functions/ I have several functions I would like to get the phase and group delay. In python I did the following
from sympy import pi, Symbol, I , atan, im, re, simplify, collect, trigsimp, sign
fr = Symbol('fr', real=True)
fo = Symbol('fo', real=True)
fn = Symbol('fn', real=True)
f = Symbol('f',real=True)
q = Symbol('q', real=True)
qn = Symbol('qn', real=True)
wr = 2*pi*fr
wo = 2*pi*fo
wn = 2*pi*fn
w = 2*pi*f
s = I*w
# Lp1 - s domain
H_lp1 = wr/(s+wr)
(re_part,im_part) = H_lp1.expand(complex=True).as_real_imag()
H_lp1_ph = atan(im_part/re_part)
Which returns the correct answer but when I try a more complicated function such as
H_lpn2 = ((s**2+wn**2)*(wo/wn)**2)/(s**2+s*(wo/q)+wo**2)
(re_part,im_part) = H_lpn2.expand(complex=True).as_real_imag()
H_lpn2_ph_expanded = atan(im_part/re_part)
H_lpn2_ph = simplify(H_lpn2_ph_expanded)
It does not return the complete solution. Any ideas?
leftiTue, 01 Sep 2015 12:07:21 -0500http://ask.sagemath.org/question/29386/Can FEniCS be setup on Sagemath Cloud?http://ask.sagemath.org/question/11002/can-fenics-be-setup-on-sagemath-cloud/Is it possible to have the FEniCS packages setup on Sagemath Cloud? http://fenicsproject.org/about/
Has anyone had success with attempting this on Sagemath? I had tried initially through a terminal instance with no success.
Regards,
BrunoBruno_BateThu, 06 Feb 2014 07:15:14 -0600http://ask.sagemath.org/question/11002/How can I save an image from sage plot ?http://ask.sagemath.org/question/10002/how-can-i-save-an-image-from-sage-plot/I am working on a project that needs the graph image generated by sage to save to disk then that would be retrieved in the application. Here is the code I am writing for generating a Graph<br>
<br>
G=Graph({'a': {'c': 25, 'b': 26, 'e': 30, 'd': 35}, 'c': {'a': 25, 'b': 33, 'e':
27, 'd': 7}, 'b': {'a': 26, 'c': 33, 'e': 34, 'd': 7}, 'e': {'a': 30,
'c': 27, 'b': 34, 'd': 9}, 'd': {'a': 35, 'c': 7, 'b': 7, 'e': 9}})
G.weighted(True)
E = kruskal(G, check=True)
print E
tot=[]
kcost=0;totcost=0
for key in E:
tot.append((key[0],key[1]))
kcost=kcost+key[2]
rev=tot[::-1]
for key in rev:
tot.append((key[1],key[0]))
path=[]
tot1=[]
for key in E:
tot1.append((key[0],key[1]))
tot1.append((key[0],key[1]))
kcost=kcost+key[2]
for p in tot1:
if p[0] not in path:
path.append(p[0])
if p[1] not in path:
path.append(p[1])
print path
print tot1
kcost=totcost/2
print tot,totcost,kcost
N=Graph(E)
N.show()
N1=Graph(tot1)
N1.show()
N.show() and N1.show() will show the Graph describing Now I am facing error running the file and generating image and my image viewer gives me error as in this post of your Google + community I have posted
https://plus.google.com/u/0/113942220708315173370/posts/jScisbFzeDr
So I am Planning to save the image at my selected location and fetch the image from that Position.
for that I am using in my code and unsure where to supply a or how to save it Please suggest me how should I save the Images from show() method.
I am using Python2.7 does it require some additional package of sagemath.
N1=Graph(tot)
a=N1.show()
newimage=Image.new("RGB",(500,500),"white")
newimage.load()
newimage.save("out.png")Chitrank DixitMon, 08 Apr 2013 02:36:12 -0500http://ask.sagemath.org/question/10002/How to locate sage at Python shellhttp://ask.sagemath.org/question/9961/how-to-locate-sage-at-python-shell/I am using sage on Localhost and on Sage command Shell but I am unable to use it with Python Command Shell. I am working on a Project that needs Tkinter to take User Input and Sage to produce the Output.
Is there any way to use Sage with Tkinter (Sorry I am new to Sage if this might be a weird question)Chitrank DixitSat, 30 Mar 2013 11:56:15 -0500http://ask.sagemath.org/question/9961/Python compiler in Sage Notebookhttp://ask.sagemath.org/question/9298/python-compiler-in-sage-notebook/Do you know which version of Python has been providing in Sage Notebook?FastfootWed, 05 Sep 2012 11:02:26 -0500http://ask.sagemath.org/question/9298/[Solved] Difference about divide operator in python2 and sagehttp://ask.sagemath.org/question/8574/solved-difference-about-divide-operator-in-python2-and-sage/I am writing a package (I want to use "import" to import it into sage).
I found that in the package (say, test.py), if I write
from sage.all import *
def test():
var('a')
print -1/2, -a/2, (-1/2)*a
and in sage type
import test; test.test()
I got "-1 -1/2*a -a"
This is different from directly run the above commands from sage.
I know in python 2, -1/2 returns -1. But is there a way to write "minus one half" (-1/2) in a package, say, test.py?
I know I could use load or attach to load a .sage package. However, they don't have namespace and I hope to have namespace as in python.
I could also use 1/2.0, which returns 0.5. But I would want an exact number instead of a float point approximation, for further use.
To summarize, in this case, how to write -1/2 in test.py? Or is there a way to load a sage package with namespace? Thanks!tririverSat, 17 Dec 2011 08:00:38 -0600http://ask.sagemath.org/question/8574/