variables not defined in numpy.random __init.py__ ?
Using PyInstaller, the following error occurs: Traceback (most recent call last): File "<string>", line 9, in <module> File "//usr/lib/python2.7/dist-packages/PIL/Image.py", line 355, in init __import__(f, globals(), locals(), []) File "//usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py", line 23, in <module> import os, tempfile File "/usr/lib/python2.7/tempfile.py", line 34, in <module> from random import Random as _Random File "//usr/lib/python2.7/dist-packages/numpy/random/__init__.py", line 90, in <module> ranf = random = sample = random_sample NameError: name 'random_sample' is not defined Is line 90 in __init.py__ valid?
On Mon, Mar 25, 2013 at 4:23 PM, Dinesh B Vadhia
** Using PyInstaller, the following error occurs:
Traceback (most recent call last): File "<string>", line 9, in <module> File "//usr/lib/python2.7/dist-packages/PIL/Image.py", line 355, in init __import__(f, globals(), locals(), []) File "//usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py", line 23, in <module> import os, tempfile File "/usr/lib/python2.7/tempfile.py", line 34, in <module> from random import Random as _Random File "//usr/lib/python2.7/dist-packages/numpy/random/__init__.py", line 90, in <module> ranf = random = sample = random_sample NameError: name 'random_sample' is not defined
Is line 90 in __init.py__ valid?
It is. Above the failing you see a line "from info import __all__", and in random/info.py you'll see that `random_sample` is in the __all__ dict. Somehow it disappeared for you, you'll need to do some debugging to find out why. Ralf
On Mon, Mar 25, 2013 at 12:51 PM, Ralf Gommers
On Mon, Mar 25, 2013 at 4:23 PM, Dinesh B Vadhia < dineshbvadhia@hotmail.com> wrote:
** Using PyInstaller, the following error occurs:
Traceback (most recent call last): File "<string>", line 9, in <module> File "//usr/lib/python2.7/dist-packages/PIL/Image.py", line 355, in init __import__(f, globals(), locals(), []) File "//usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py", line 23, in <module> import os, tempfile File "/usr/lib/python2.7/tempfile.py", line 34, in <module> from random import Random as _Random File "//usr/lib/python2.7/dist-packages/numpy/random/__init__.py", line 90, in <module> ranf = random = sample = random_sample NameError: name 'random_sample' is not defined
Is line 90 in __init.py__ valid?
It is.
In my reading of this the main problem is that `tempfile` is trying to import `random` from the Python standard library but instead is importing the one from within NumPy (i.e., `numpy.random`). I suspect that somehow `sys.path` is being set incorrectly --- perhaps because of the `PYTHONPATH` environment variable. -Brad
@ Ralf. I missed info.py at the top and it is a valid statement.
@ Brad. My project is using Numpy and Scipy and falls over at this point when using PyInstaller. One of the project source files has an "import random" from the Standard Library. As you say, at this point in tempfile.py, it is attempting to "import random" from the Standard Library but instead is importing the one from Numpy (numpy.random). How can this be fixed? Or, is it something for PyInstaller to fix? Thx.
From: Bradley M. Froehle
Sent: Monday, March 25, 2013 1:26 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] variables not defined in numpy.random__init.py__ ?
On Mon, Mar 25, 2013 at 12:51 PM, Ralf Gommers
On Tue, Mar 26, 2013 at 9:46 AM, Dinesh B Vadhia
** @ Ralf. I missed info.py at the top and it is a valid statement.
@ Brad. My project is using Numpy and Scipy and falls over at this point when using PyInstaller. One of the project source files has an "import random" from the Standard Library. As you say, at this point in tempfile.py, it is attempting to "import random" from the Standard Library but instead is importing the one from Numpy (numpy.random). How can this be fixed? Or, is it something for PyInstaller to fix? Thx.
Probably the latter. Check your PYTHONPATH is not set and you're not doing anything to sys.path somehow. Then probably best to ask on the PyInstaller mailing list. Ralf
*From:* Bradley M. Froehle
*Sent:* Monday, March 25, 2013 1:26 PM *To:* Discussion of Numerical Python *Subject:* Re: [Numpy-discussion] variables not defined in numpy.random__init.py__ ? On Mon, Mar 25, 2013 at 12:51 PM, Ralf Gommers
wrote: On Mon, Mar 25, 2013 at 4:23 PM, Dinesh B Vadhia < dineshbvadhia@hotmail.com> wrote:
** Using PyInstaller, the following error occurs:
Traceback (most recent call last): File "<string>", line 9, in <module> File "//usr/lib/python2.7/dist-packages/PIL/Image.py", line 355, in init __import__(f, globals(), locals(), []) File "//usr/lib/python2.7/dist-packages/PIL/IptcImagePlugin.py", line 23, in <module> import os, tempfile File "/usr/lib/python2.7/tempfile.py", line 34, in <module> from random import Random as _Random File "//usr/lib/python2.7/dist-packages/numpy/random/__init__.py", line 90, in <module> ranf = random = sample = random_sample NameError: name 'random_sample' is not defined
Is line 90 in __init.py__ valid?
It is.
In my reading of this the main problem is that `tempfile` is trying to import `random` from the Python standard library but instead is importing the one from within NumPy (i.e., `numpy.random`). I suspect that somehow `sys.path` is being set incorrectly --- perhaps because of the `PYTHONPATH` environment variable.
-Brad
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
participants (3)
-
Bradley M. Froehle
-
Dinesh B Vadhia
-
Ralf Gommers