sgoldenlab / simba

SimBA (Simple Behavioral Analysis), a pipeline and GUI for developing supervised behavioral classifiers
https://simba-uw-tf-dev.readthedocs.io/
GNU General Public License v3.0
279 stars 138 forks source link

Fail to start SimBA due to incorrect splash image name #192

Closed florianduclot closed 2 years ago

florianduclot commented 2 years ago

Describe the bug In a conda environment under Linux, starting simba fails with the following:

# simba                                                                                                                                                                                                    (simbaenv) 135ms  Wed 06 Jul 2022 09:51:09 AM EDT
Traceback (most recent call last):
  File "/home/florian/miniconda3/envs/simbaenv/bin/simba", line 8, in <module>
    sys.exit(main())
  File "/home/florian/miniconda3/envs/simbaenv/lib/python3.6/site-packages/simba/SimBA.py", line 8082, in main
    app = SplashScreen(root)
  File "/home/florian/miniconda3/envs/simbaenv/lib/python3.6/site-packages/simba/SimBA.py", line 8045, in __init__
    self.Splash()
  File "/home/florian/miniconda3/envs/simbaenv/lib/python3.6/site-packages/simba/SimBA.py", line 8053, in Splash
    self.image = PIL.Image.open(os.path.join(scriptdir, "splash_050122.PNG"))
  File "/home/florian/miniconda3/envs/simbaenv/lib/python3.6/site-packages/PIL/Image.py", line 2634, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/home/florian/miniconda3/envs/simbaenv/lib/python3.6/site-packages/simba/splash_050122.PNG'

To Reproduce Steps to reproduce the behavior: Install simba in a conda env:

conda create -n simbaenv python=3.6.10 wxpython==4.0.4
conda activate simbaenv
pip install simba-uw-tf-dev
simba

Expected behavior Simba starts successfully.

Desktop (please complete the following information):

I indeed do not see the requested file in the installed simba package, but I do see that the file is present with the png extension in lower case. Changing this to lower case in simBA.py indeed seems to fix the issue and allow simba to start successfully. See below:

Wed 06 Jul 2022 10:00:02 AM EDT
--- SimBA.py    2022-07-06 09:58:16.023680043 -0400
+++ SimBA_patched.py    2022-07-06 09:59:35.350019182 -0400
@@ -8050,7 +8050,7 @@
         if currentPlatform == 'Windows':
             self.image = PIL.Image.open(os.path.join(scriptdir,"splash_050122.png"))
         if (currentPlatform == 'Linux') or (currentPlatform == 'Darwin'):
-            self.image = PIL.Image.open(os.path.join(scriptdir, "splash_050122.PNG"))
+            self.image = PIL.Image.open(os.path.join(scriptdir, "splash_050122.png"))
         self.imgSplash = ImageTk.PhotoImage(self.image)

Of course, the distinction between platforms there seems redundant if the filename is now the same... Hope this helps,

sronilsson commented 2 years ago

Super helpful @florianduclot :) In the past, i've found that the PIL package required the png to be capitalized on mac or linux, even though the true file extension isn't actually capitalized... what I'll do is insert an exception, and hope that it covers it, e.g.

if (currentPlatform == 'Linux') or (currentPlatform == 'Darwin'):
    try:
        self.image = PIL.Image.open(os.path.join(scriptdir, "splash_050122.PNG"))
    except FileNotFoundError:
        self.image = PIL.Image.open(os.path.join(scriptdir, "splash_050122.png"))
florianduclot commented 2 years ago

Sounds good! Thanks a lot for yet another very prompt answer!