git and site-package coexistence

16 views
Skip to first unread message

smichr

unread,
Jun 6, 2009, 10:12:35 PM6/6/09
to sympy
I am having some problems with sympy and am wondering if it is related
to sympy being in a git directory and in my site-packages. What I have
been doing to run sympy is to copy all files from the git directory
into my site-packages directory. But today I ran into a strange
problem where something I was passing to the roots routine was not
being received. And in the traceback I saw that I had a mix of files
involved, some from my site-packages and one from the git directory.

The source code file that I was working with was on the desktop.

###
1 sending to roots: 1/x x
2 Traceback (most recent call last):
3 File "<interactive input>", line 1, in <module>
4 File "C:\Documents and Settings\chris\Desktop\symp.py", line 740,
in solv
5 rv= solv1(f, symbol)
6 File "C:\Documents and Settings\chris\Desktop\symp.py", line
1173, in solv1
7 rv.extend(roots((lhs-rhs).as_poly(symbol), cubics=True,
quartics=True).keys())
8 File "C:\Documents and Settings\chris\sympy\sympy\polys
\rootfinding.py", line 190, in roots
9 f = Poly(f, *symbols)
10 File "C:\Python26\lib\site-packages\sympy\polys\polynomial.py",
line 300, in __new__
11 raise SymbolsError("No symbols were given")
12 SymbolsError: No symbols were given
###

(Line numbers are my own in the above.) In line 1
I print what I am sending to the roots routine.
But in line 8 the git directory version of rootfinding is being
referenced.
And then in 10, a file in the site-packages is being referenced.

How do others incorporate their git directory into python locally? Do
you make the git directory for sympy in site-packages, put it on the
path and use only that copy, or something else?

Thanks for any help,
/c

Robert Kern

unread,
Jun 6, 2009, 10:18:49 PM6/6/09
to sy...@googlegroups.com

The easiest thing for you to do is add a file named "sympy.pth" into
your site-packages. It should have just one line: the full path to
your git checkout. For example, I have my checkout in
/Users/rkern/git/sympy/ (i.e. /Users/rkern/git/sympy/setup.py exists).
Thus, I would have just the line

/Users/rkern/git/sympy

in my .pth file.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco

Aaron S. Meurer

unread,
Jun 6, 2009, 10:56:28 PM6/6/09
to sy...@googlegroups.com
I just cd into the git directory (I don't know if such a thing is
possible in Windows). If I import sympy and my working directory is
the git directory, it finds that sympy first, and uses it. Otherwise,
if my working directory is any other directory, it uses the installed
version of sympy. Fink also puts an "isympy-py26" in my path that is
a symbolic link to the installed sympy. If whatever runs python in
Windows doesn't seem to allow you to change the working directory, you
can do

import os
os.chdir("<path-to-git-sympy>")

I think Robert's hint will make it so that it always finds the git
sympy first, if that's what you want (I don't know for sure though.
Test it).

Aaron Meurer

smichr

unread,
Jun 7, 2009, 3:40:36 AM6/7/09
to sympy
> The easiest thing for you to do is add a file named "sympy.pth" into
> your site-packages. It should have just one line: the full path to
> your git checkout. For example, I have my checkout in
> /Users/rkern/git/sympy/ (i.e. /Users/rkern/git/sympy/setup.py exists).
> Thus, I would have just the line
>
> /Users/rkern/git/sympy
>



On Jun 7, 7:18 am, Robert Kern <robert.k...@gmail.com> wrote:
> The easiest thing for you to do is add a file named "sympy.pth" into
> your site-packages. It should have just one line: the full path to
> your git checkout. For example, I have my checkout in
> /Users/rkern/git/sympy/ (i.e. /Users/rkern/git/sympy/setup.py exists).

OK, here's a demonstration that 'setup.py' exists like in your
example:

---
>dir "C:\Documents and Settings\chris\sympy
\setup.py"
Volume in drive C is BB_2
Volume Serial Number is 0482-A52E

Directory of C:\Documents and Settings\chris\sympy

05/11/2009 05:04 AM 8,275 setup.py
1 File(s) 8,275 bytes
0 Dir(s) 83,333,206,016 bytes free
---

And this is what is in the pth file. I used quotes since the path has
spaces in it:

---
>more \python26\lib\site-packages\sympy.pth

"C:/Documents and Settings/chris/sympy/"
---

But when I start python and try to load sympy I get

###
>>> from sympy import *
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
ImportError: No module named sympy
>>>
###

Do you have other ideas for a windows system or can you see what I did
wrong?

/c

Robert Kern

unread,
Jun 7, 2009, 3:52:29 AM6/7/09
to sy...@googlegroups.com
On Sun, Jun 7, 2009 at 02:40, smichr <smi...@gmail.com> wrote:
> On Jun 7, 7:18 am, Robert Kern <robert.k...@gmail.com> wrote:
>> The easiest thing for you to do is add a file named "sympy.pth" into
>> your site-packages. It should have just one line: the full path to
>> your git checkout. For example, I have my checkout in
>> /Users/rkern/git/sympy/ (i.e. /Users/rkern/git/sympy/setup.py exists).
>
> OK, here's a demonstration that 'setup.py' exists like in your
> example:
>
> ---
>>dir "C:\Documents and Settings\chris\sympy
> \setup.py"
>  Volume in drive C is BB_2
>  Volume Serial Number is 0482-A52E
>
>  Directory of C:\Documents and Settings\chris\sympy
>
> 05/11/2009  05:04 AM             8,275 setup.py
>               1 File(s)          8,275 bytes
>               0 Dir(s)  83,333,206,016 bytes free
> ---
>
> And this is what is in the pth file. I used quotes since the path has
> spaces in it:

Try it without the quotes. Entries are separated by newlines, not
arbitrary whitespace, so quotes are unnecessary. Examine your
sys.path.

Vinzent Steinberg

unread,
Jun 7, 2009, 5:38:17 AM6/7/09
to sympy
You could also "hack" your sys.path to make sure the correct sympy
gets imported first, i.e.:

>>> sys.path.insert(0, 'C:/Documents and Settings/chris/sympy/')
>>> sys.path
['C:/Documents and Settings/chris/sympy/', '', 'C:\\Python26\
\python26.zip', 'C:
\\Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win',
'C:\\Pyth
on26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-
packages']

This is however not a clean solution (rather a security hole), but it
should work.

cd'ing to your sympy directory also works fine on Windows.

Vinzent

smichr

unread,
Jun 7, 2009, 5:35:24 PM6/7/09
to sympy

>
> Try it without the quotes. Entries are separated by newlines, not
> arbitrary whitespace, so quotes are unnecessary. Examine your
> sys.path.
>
> --

That was the solution. Thanks to all that gave suggestions. I like the
idea of the *pth file since it allows me to see in the site-packages
folder what's "installed" as a package.

/c

Ondrej Certik

unread,
Jun 8, 2009, 3:05:19 PM6/8/09
to sy...@googlegroups.com

Chris -- if you have time, could you please write a short howto to get
sympy up and running on windows? The above trick is I think very
useful. It would go to:

http://docs.sympy.org/sympy-patches-tutorial.html

Just add there a new section how to get it working on windows by
editing doc/src/sympy-patches-tutorial.txt. This file has to be
updated anyways, I am even thinking of creating some video tutorials
about git + sympy, as that might be the most effective.

Ondrej

Ondrej Certik

unread,
Jun 8, 2009, 3:07:55 PM6/8/09
to sy...@googlegroups.com

Here is the easy-to-fix issue for it:

http://code.google.com/p/sympy/issues/detail?id=1464

O.

Reply all
Reply to author
Forward
0 new messages