I am not 100% sure as I appeared to just have it without trying when we updated to a UV version with Python. Mike will likely have more info, but something really easy to try is to just add the VOC entry. Here is mine:
I will warn you that I have had some minor issues with the REINIT.PYTHON when running some code. For example, when logging, I would get an additional log entry for every time I reran the program without logging back in.
First time: Logs once
Second time: Logs twice
Third time: Logs three times
...and so on
HOWEVER! We recently updated to UV 12.X.X and on a couple of the modules I have tried (Numpy, XLRD) have both had the issues fixed without having to use REINIT.PYTHON There may be modules that will still need it...but thus far no issues.
------------------------------
Nic Davidson
Developer
Combined Transport Inc
Medford OR United States
------------------------------
Original Message:
Sent: 09-17-2021 11:37
From: Joseph Miele
Subject: UV Python Numpy Crash
This seemed like a useful way to solve the same problem that I am having with NumPy, but I don't seem to have that command on my Universe.
Verb "REINIT.PYTHON" is not in your VOC.
How do I get this very helpful feature?
Joe Miele
------------------------------
Joseph Miele
Self Registered
Clinton IA United States
Original Message:
Sent: 11-05-2020 14:07
From: Mike Rajkowski
Subject: UV Python Numpy Crash
Nic,
I like the setting of REINIT.PYTHON from Python. I tend to decide if I want it on or off for an account and/or user and add the REINIT.PYTHON OFF to the LOGIN paragraph of the account in question, yet since there may be times you need to use a package that requires it off, you method looks promising.
------------------------------
Michael Rajkowski
Rocket Software
Original Message:
Sent: 11-05-2020 13:16
From: Nic Davidson
Subject: UV Python Numpy Crash
Michael,
After adding the command to VOC this worked perfectly! Thanks!
For anyone else having the issue this is what I ended up doing to make life easier:
Made a new (really tiny) module:
u2_numpy
-- __init__.py
-- u2_numpy.py
File contents:
__init__.py:
from .u2_numpy import *
u2_numpy.py:
# I made some changes to u2py and have my own version. This line could be just import u2py
import u2py_new as u2py
command = u2py.Command("REINIT.PYTHON OFF")
command.run()
import numpy
In any module/file where I need to use numpy just do:
import u2_numpy as numpy
And you should be good to go! No issues for me as of yet.
You would have to do this again if you wanted s different numpy type module (EX: Pandas). Potential way around this would be adding the u2py command to Numpy...but then you would have to "fix" it again on each package update.
------------------------------
Nic Davidson
Combined Transport
Original Message:
Sent: 10-28-2020 13:50
From: Michael Rajkowski
Subject: UV Python Numpy Crash
Nic,
When UniVerse exits the Python shell, it re-initializes the Python environment. Some packages (numpy being one of them ) make changes that are not affected by the initialization and cause problems when imported again.
Set the REINIT.PYTHON to OFF, and it should stop it from aborting.
i.e.
>REINIT.PYTHON OFF
>PYTHON
python> import numpy
python> quit()
>PYTHON
python> import numpy
python>
Note that I plan to look a bit deeper into the abort, since it is a bit drastic.
------------------------------
Michael Rajkowski
Rocket Software
Original Message:
Sent: 10-28-2020 11:12
From: Nic Davidson
Subject: UV Python Numpy Crash
I am having an issue I am hoping a bright mind around here can help me with. It seems that something in the Python interpreter is not cleaning up after itself after importing the NumPy library. In reality I was trying to use Pandas, but after some trial and error I think I have identified NumPy as the culprit.
Replicating this is easy, after installing NumPy:
From TCL:
PYTHON
import numpy
quit()
PYTHON
import numpy
Will crash every time. Same results from running the code from a python file.
Having the ability to use NumPy would really enable some great functionality in UV and I would really like to get this working. Is anyone else having a similar issue?
------------------------------
Nic Davidson
Combined Transport
------------------------------