the Qt platform plugin

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

the Qt platform plugin

Post by RBJ » Sun Aug 13, 2017 3:21 pm

Hello All,
I have tended to work in HOC.... but am moving now to Python.
I get this error:

"This application failed to start because it could not find or load the Qt platform plugin "windows" in "". "
..when I try to run any script that includes

Code: Select all

from matplotlib import pyplot
pyplot.figure(figsize=(8,4))
I am running NEURON 7.5 on Windows 8.1, but tried with 7.4 initially. My Python is 2.7 from Anaconda.
I have tried uninstalling and re-installing and assume that there is a missing element to the PATH or a missing enviromental variable?
Can anyone suggest to me how to approach diagnosing the error in the first instance. Hopefully a cure will logically follow from a diagnosis!
Kind Regards
Richard

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Wed Aug 16, 2017 5:36 pm

So this still doesn't work for me, but I see the

Code: Select all

def Section(name):
  h("create "+name)
  return h.__getattribute__(name)
"trick" illustrated on this very site serves as an alternative. Allowing full use of the Neuron GUI!

ted
Site Admin
Posts: 5057
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: the Qt platform plugin

Post by ted » Fri Aug 18, 2017 4:29 pm

RBJ wrote:I get this error:

"This application failed to start because it could not find or load the Qt platform plugin "windows" in "". "
..when I try to run any script that includes

Code: Select all

from matplotlib import pyplot
pyplot.figure(figsize=(8,4))
I am running NEURON 7.5 on Windows 8.1, but tried with 7.4 initially. My Python is 2.7 from Anaconda.
I have tried uninstalling and re-installing and assume that there is a missing element to the PATH or a missing enviromental variable?
First question: are you able to just start python all by itself, and then, at the >>> prompt,

Code: Select all

from matplotlib import pyplot
pyplot.figure(figsize=(8,4))
?

If yes, try the following:
Find out where your python installation is located--it's probably in a directory called c:\python27
Assuming that is the case, then start a bash terminal (use the icon in the NEURON program group). In that terminal, execute these statements

Code: Select all

export PYTHONHOME=/c/python27
export NRN_PYLIB=/c/python27/python27.dll
Then, in that same bash terminal, execute this command

Code: Select all

nrniv -python
and you should get the familiar python >>> prompt. Now execute

Code: Select all

from neuron import h
and if that works try

Code: Select all

from matplotlib import pyplot
pyplot.figure(figsize=(8,4))
again.

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Mon Aug 21, 2017 3:19 pm

Thanks, yes Matplotlib works fine through Python itself (Anaconda2), but exporting those environmental variables did not do the trick. Same error. I am thinking that somewhere among all my environmental variables there is probably a backslash where there should be a forward slash or visa versa? It's low priority since I can use the NEURON gui plotting. It would just allow me to run a colleagues models without editing that's all.

ramcdougal
Posts: 94
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: the Qt platform plugin

Post by ramcdougal » Tue Aug 22, 2017 12:39 pm

Are you able to import neuron from the regular Python prompt?

If so, consider that as a work-around; i.e. launch your simulation through python instead of through NEURON. If not, that can be fixed by adjusting your PYTHONPATH and maybe NEURONHOME environment variables.

hines
Site Admin
Posts: 1436
Joined: Wed May 18, 2005 3:32 pm

Re: the Qt platform plugin

Post by hines » Tue Aug 22, 2017 4:36 pm

If you start the bash terminal supplied by the NEURON 7.5 installation, and unset PYTHONHOME and then run
nrnpyenv,sh
it will print a number of environment variables needed for python to work when launching nrniv. In fact nrnpyenv.sh is automatically run when you start the bash terminal and exports the PYTHONPATH (needed to import neuron if you launch python) and PYTHONHOME and NRN_PYLIB ( needed if you launch nrniv -python) . In your case, I suspect you need a more extensive PYTHONPATH when launching nrniv in order to find QT. One way of diagnosing is to compare the result of
import sys
sys.path
when launching python and nrniv -python
which may indicate what is missing. Another hint can perhaps be gleaned by launching python and importing a module and then determining its location with <module>.__file__

ted
Site Admin
Posts: 5057
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: the Qt platform plugin

Post by ted » Tue Aug 22, 2017 8:03 pm

When this discussion concludes, I think I'll move it to the
NEURON + Python
area of the forum, for which it seems most appropriate.

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Sun Aug 27, 2017 3:05 am

ramcdougal wrote:Are you able to import neuron from the regular Python prompt?

If so, consider that as a work-around; i.e. launch your simulation through python instead of through NEURON. If not, that can be fixed by adjusting your PYTHONPATH and maybe NEURONHOME environment variables.
No I'm sorry that doesn't work. "ImportError:DLL lad failed"

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Sun Aug 27, 2017 3:22 am

hines wrote:If you start the bash terminal supplied by the NEURON 7.5 installation, and unset PYTHONHOME and then run
nrnpyenv,sh
it will print a number of environment variables needed for python to work when launching nrniv. In fact nrnpyenv.sh is automatically run when you start the bash terminal and exports the PYTHONPATH (needed to import neuron if you launch python) and PYTHONHOME and NRN_PYLIB ( needed if you launch nrniv -python) .
Thank you, the unset and run of nrnpyenv.sh produced sensible output, but all looks like it should and that I already have when I run nrniv_python. I am still nervous about forward vs double vs backward slashes though. Can inherent complication of mixing windows vs unix systems.
hines wrote: In your case, I suspect you need a more extensive PYTHONPATH when launching nrniv in order to find QT. One way of diagnosing is to compare the result of
import sys
sys.path
when launching python and nrniv -python
which may indicate what is missing.
Not sure how I see the import sys and sys.path when I launch these?
hines wrote: Another hint can perhaps be gleaned by launching python and importing a module and then determining its location with <module>.__file__
The location I got for matplotlib.__file__ is very different to anything that I recognise in my paths. It has "site-packages" in the mists of the output; I don't recall seeing before. I'll look into this!

hines
Site Admin
Posts: 1436
Joined: Wed May 18, 2005 3:32 pm

Re: the Qt platform plugin

Post by hines » Sun Aug 27, 2017 9:04 am

Please copy/paste the banner shown when nrniv is launched.
If your 7.5 version is several months prior to the latest version at
http://www.neuron.yale.edu/ftp/neuron/versions/alpha/
please reinstall.

What is shown when you unset PYTHONHOME and execute in a bash terminal
nrnpyenv.sh

WIndows knows nothing about '/' forward slashes, but python and the bash terminal generally
allow syntax like
/c/nrn
c:/nrn

What does the following print
python
import sys
sys.path

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Sat Sep 30, 2017 11:16 am

OK, thanks it actually was an August release I think, but I went for re-install anyway. Naturally I can't run any of my scripts now, so I am making a very fresh start.
The banner NOW is:

Code: Select all

NEURON -- VERSION 7.5 master (6b4c19f) 2017-09-25
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

>>>
Don't recall how to unset PYTHONHOME....
but if I run nrnpyenv.sh I get:

Code: Select all

bash.exe"-3.1$ nrnpyenv.sh
# items in sys.path = 16
# beginning with sys.prefix = 13
# beginning with site-3 = 13
# in neither location ['.', '/c/nrn/ningw/bin', '/c/nrn/lib/python']
# sys.prefix = /c/ProgramData/Anaconda2
# site-3 = /c/ProgramData

# if launch python, then need:
export PYTHONPATH="/c/ProgramData/Anaconda2:/c/nrn/ningw/bin:/c/ProgramData/Anaconda2/scripts:/c/nrn/lib/python"

# if launch nrniv, then likely need:
export PYTHONHOME="/c/ProgramData/Anaconda2"
export PATH="/c/ProgramData/Anaconda2/Library/bin:$PATH"
export NRN_PYLIB="c:/ProgramData/Anaconda2/python27.dll"
bash.exe"-3.1$
If I run
import sys
from my new nrn_python window
I get

Code: Select all

['c:\\nrn\\bin', '', 'c:\\nrn\\bin', 'c:\\ProgramData\\Anaconda2', 'c:\\nrn\\nin
gw\\bin', 'c:\\ProgramData\\Anaconda2\\scripts', 'c:\\nrn\\lib\\python', 'c:\\Pr
ogramData\\Anaconda2\\python27.zip', 'c:\\ProgramData\\Anaconda2\\DLLs', 'c:\\Pr
ogramData\\Anaconda2\\lib', 'c:\\ProgramData\\Anaconda2\\lib\\plat-win', 'c:\\Pr
ogramData\\Anaconda2\\lib\\lib-tk', 'c:\\nrn\\bin', 'c:\\ProgramData\\Anaconda2\
\lib\\site-packages', 'c:\\ProgramData\\Anaconda2\\lib\\site-packages\\Sphinx-1.
6.2-py2.7.egg', 'c:\\ProgramData\\Anaconda2\\lib\\site-packages\\win32', 'c:\\ProgramData\\Anaconda2\\lib\\site-packages\\win32\\lib', 
'c:\\ProgramData\\Anaconda2\\lib\\site-packages\\Pythonwin', 'c:\\ProgramData\\Anaconda2\\lib\\site-packages\\setuptools-27.2.0-py2.7.egg', 'c:/nrn/lib/python']
I am not quite sure what to do now... having re-installed Neuron, of course I can't run any of my scripts (I presume because the paths are all wrong), but I wondered if I should await advice before re-setting that up in case it is the very way I did it that created the problem in the first place?
Thank you for your help.
Richard

hines
Site Admin
Posts: 1436
Joined: Wed May 18, 2005 3:32 pm

Re: the Qt platform plugin

Post by hines » Sat Sep 30, 2017 6:31 pm

Don't recall how to unset PYTHONHOME....
If you start a bash terminal, and don't

Code: Select all

unset PYTHONHOME
then you should have seen

Code: Select all

bash.exe"-3.1$ nrnpyenv.sh
# PYTHONHOME exists. Do nothing
bash.exe"-3.1$
But I see that you got the proper output from nrnpyenv.sh . If you did not unset PYTHONHOME yourself, then this implies that the PYTHONHOME and NRN_PYLIB variables were not set. I want to verify that, so please
start another bash terminal and tell the results of

Code: Select all

echo $PYTHONHOME
echo $NRN_PYLIB
echo $PYTHONPATH
If I run
import sys
from my new nrn_python window
I get
I assume you mean that you double clicked the nrniv_python icon and that after 'import sys' you typed sys.path. Anyway, apart from the strange result that you got output from nrnpyenv.sh from a bash terminal
without first unsetting PYTHONHOME, the output you pasted seems correct. When I start a nrniv_python window I can successfully show a matplotlib window

Code: Select all

NEURON -- VERSION 7.5 master (6b4c19f) 2017-09-25
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

>>> from matplotlib import pyplot
>>> pyplot.figure(figsize=(8,4))
<matplotlib.figure.Figure object at 0x0000000002D38978>
>>> pyplot.show()
Although I cannot say from the appearance of the plot window that it was made by qt, sys.module.keys() does show a matplotlib.backends.qt5 item.

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Sun Oct 01, 2017 9:09 am

Thank you very much.
Firstly, the "unset PYTHONHOME" thing. Now I have rebooted and restarted, I get your expected bash responses.

Code: Select all

bash.exe"-3.1$ nrnpyenv.sh
# PYTHONHOME exists. Do nothing
Now when I run:

Code: Select all

echo $PYTHONHOME
echo $NRN_PYLIB
echo $PYTHONPATH
I get:

Code: Select all

bash.exe"-3.1$ echo $PYTHONHOME
/c/ProgramData/Anaconda2
bash.exe"-3.1$ echo $NRN_PYLIB
c:/ProgramData/Anaconda2/python27.dll
bash.exe"-3.1$ $PYTHONPATH
bash.exe": /c/ProgramData/Anaconda2:/c/nrn/ningw/bin:/c/ProgramData/Anaconda2/sc
ripts:/c/nrn/lib/python:/c/nrn/lib/python
bash.exe"-3.1$


Still Qt fails, but the import of Matplotlib itself still works

Code: Select all

>>> from matplotlib import pyplot
>>> pyplot.figure(figsize=(8,4))
This application failed to start because it could not find or load the Qt platfo
rm plugin "windows"
in "".

Reinstalling the application may fix this problem.

NEURON exited abnormally. Press the return key to close this window

RBJ
Posts: 32
Joined: Sun Aug 02, 2015 4:28 am

Re: the Qt platform plugin

Post by RBJ » Sun Oct 01, 2017 9:31 am

Ah!
Not quite sure what this means, but reading your posts over and over, I just used bash to launch python RATHER than nrniv_python and now Qt is running.

So I am sure this must mean something...

and in fact if we can fix this it will fix a whole series of issues I was having with Neuron Python I didn't understand. Such as it was refusing to allow me to use regular functions like open("textfile.txt") etc etc....
When I use the Bash route, those now work too.
..and Oh my gosh Spyder works via that route too!!!!
Do I even need nrniv_python? Am I good to go like this?
So excited
Richard

hines
Site Admin
Posts: 1436
Joined: Wed May 18, 2005 3:32 pm

Re: the Qt platform plugin

Post by hines » Sun Oct 01, 2017 11:06 am

You don't need to use nrniv_python. It is (intended to be) equivalent to starting a bash terminal and executing 'nrniv -python' in it.
However, i am puzzled why the direct bash terminal followed by typing 'nrniv -python' and nrniv_python are not doing the same thing.
A good diagnostic might be to compare in both situations the output of
import sys
print (sys.path)

are there any differences?

Post Reply