ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Working on a network at my job where I do not have admin access.
The python3 installation does not have the required modules so I install anaconda3 in an area where I have access.
Using the anaconda3 python I have all the modules I need and everything works as expected except that GUI apps are very slow to load - about 10 to 12 seconds. If I shutdown the GUI and immediately restart is loads within a second.
Also get this output when starting the GUI.
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-<USER>'
I can set XDG_RUNTIME_DIR but it does not affect how fast the GUI starts.
I have a home PC with all the required modules included in the system python and the same GUI loads with no 10 to 12 second delay.
Is there anyway to determine the root cause of the delay?
Wrapping cProfile around my main function and the GUI always starts relatively quickly. Logged into several machines and the behavior was consistent. I don't know what cProfile does but it makes trouble shooting this particular issue impossible because the issue cannot be duplicated with cProfile.
I could be wrong (I usually am), but I don't think the issue is with my code because the code runs perfectly on my home PC. It is only on the job network where I see the delay and it is only on a first run, subsequent runs are normal.
EDIT: Testing with cProfile and the GUI starts up normally. Removed cProfile and in the same terminal the GUI loaded slowly.
Maybe one of the dependencies is large and it's taking forever to load off a slow network share? You can easily test that by just firing up "python3" and typing in the imports.
Noticed that I can start python3 and enter "from PyQt5 import QtGui, uic, QtCore, QtWidgets" and it takes several seconds to return the prompt.
I then do ctrl-D, immediately start python3, and the import returns to the prompt immediately.
What could cause that? It appears the shell remembers the module imports from the previous python session and keeps them ready. If I wait a long time, not sure how long, before starting python a second time the imports are again slow.
What could cause that? It appears the shell remembers the module imports from the previous python session and keeps them ready. If I wait a long time, not sure how long, before starting python a second time the imports are again slow.
It's certainly because of caching that's done by the filesystem itself.
You know it will become slow if you wait a while. Do that, launch the interpreter with "python3 -v", and do the imports again.
The reason it loads faster in BASH than in tcsh could just be because you're testing in BASH right after testing in tcsh. Be aware of that possibility.
Noticed this morning that a command line invocation of python took a few seconds to get to the python prompt. Did ctrl-D and immediately restarted python and the prompt appears immediately.
So python itself is slow to load, and import of Qt modules, are both slow on an initial start.
#!/usr/bin/python
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QUrl, QSizeF
from PyQt5.QtPrintSupport import QPrinter
if __name__ == "__main__":
print (__package__)
print (__name__)
Code:
sysctl vm.drop_caches=3
#1st
time {
python3 ./atest.py
}
None
__main__
real 0m2.841s
user 0m0.098s
sys 0m0.083s
#2nd
time {
python3 ./atest.py
}
None
__main__
real 0m0.114s
user 0m0.087s
sys 0m0.027s
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.