startup python and system path problems

Anything that doesn't fit elsewhere.
Post Reply
JimH
Posts: 54
Joined: Tue Apr 10, 2007 3:36 pm
Location: Duke University

startup python and system path problems

Post by JimH »

This is more of a comment than a question.

I recently switched to NEURON 7.7 from vs 7.2 and apparently a few things have changed over the past few years!

Also important to know, I run NEURON from Matlab (using a Java process and stdin/stdout/stderr) which leads to some of these issues.

When first running 7.7, I got an error: "Permission Denied" when trying to execute Python on startup (from calling nrniv).

Here's the full error:

Code: Select all

C:/nrn/bin/nrnpyenv.sh: line 144: /cygdrive/c/Users/RNEL/AppData/Local/Microsoft/WindowsApps/python3:
Permission denied
As a first fix, I tried passing in -nopython to nrniv. This seemed to work, but then run() wasn't working for some reason. This may be because of some earlier code failure (i.e. the problem may not be with Python and run, but with Python and something else). I'm working on upgrading all of my hoc calls to check the results (e.g. chdir look for 0 to indicate success, -1 indicates failure), so it is possible the error came earlier. Anyway, I removed the nopython flag and tried to actually fix the permission problem.

I just recently "upgraded" to Windows 10 and apparently Windows Apps is a thing (see above path in the error msg). Navigating to that location I find an empty executable (size = 0 kb) which when I click on it launches a web browser to install Python. Interestingly, this doesn't fix the problem (in Matlab). However now when I now call python from a Windows terminal, python launches just fine. It apparently runs at:
...WindowsApps\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\python.exe

as determined from import sys, sys.executable

So interestingly running python by calling WindowsApps/python3 works in the command line (i.e. literally typing 'python' in the command window), but not from NEURON. nrniv, when double clicked in Windows, also launches with this error (permission denied). I can still enter statements but I haven't tested it enough to know if it would also show the same problems with executing code (i.e. run() failing).

UPDATE: It turns out after I fixed the next problem, I was able to again use the -nopython flag and the code worked. However, I didn't see the next error until I had fixed the Python path problem.

So in the nrnpyenv.sh file, I modify the code setting the PYTHON variable equal to the crazy path above (in the part just below "$WHICH python3", line 83 for me)

This path doesn't work so I finally settled on hardcoding in:

Code: Select all

  PYTHON="/cygdrive/c/Users/RNEL/Anaconda3/python.exe"
  a="/cygdrive/c/Users/RNEL/Anaconda3"
  export PATH="$a":"$PATH"
This fixes the permission denied error! Now when running my Matlab Java process code I got the error "The system cannot find the path specified"

This error is a bit more cryptic. What path? After dumping all the commands to a hoc file, I ran the file by double clicking it and it ran fine. I then tried having Matlab run the hoc file via a system() command call, this didn't work either (as opposed to my approach which was to run NEURON via a Java process). After some searching I found out this is likely a problem with my PATH environment variable. Using WindowsPathEditor (https://rix0rrr.github.io/WindowsPathEditor/) I found one path that no longer existed and removed it. I also removed my own installation of mingw from the path and some other paths that I no longer needed. Note I can't remember if I needed to remove all these paths, or if just removing the missing path was sufficient. After all of this, everything was working just fine again, like in NEURON 7.2!

Anyway, I'm not sure if there are any tidbits in here which might indicate some small tweaks are needed for NEURON or if it helps anybody else but I figured I'd document it just in case.
Post Reply