asmartin / f2.8gallery

An elegant and responsive static site generator for displaying your photography portfolio.
GNU General Public License v3.0
4 stars 0 forks source link

Windows error on build #1

Open tyeeman opened 4 days ago

tyeeman commented 4 days ago
(env) g:\f28gallery>f2.8gallery.py --title "Johns Photos" --author "John" galleries output
Traceback (most recent call last):
  File "G:\f28gallery\f2.8gallery.py", line 10, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

Any tips?

I do see pil folder within env/lib/site-packages though!

asmartin commented 4 days ago

Did you follow the installation instructions to create a python virtual environment and then install the needed python packages from requirements.txt? If so, please paste the output from running this commands so I can verify they all completed successfully (maybe there was a subtle error). From your command output it looks like the virtual environment is active so as long as there wasn't an error installing one of the packages, it should be working.

You could try the Windows-specific syntax to make sure it's working as expected:

git clone https://github.com/asmartin/f2.8gallery.git
cd f2.8gallery
python.exe -m venv env
env\Scripts\activate
pip3.exe install -r requirements.txt

Also, run where python or where pip3 to confirm it's using the version in the venv

tyeeman commented 3 days ago

OK, I deleted the env folder to start again.

g:\laragonServerPortable\www\f28gallery>python -m venv env

g:\laragonServerPortable\www\f28gallery>env\scripts\activate.bat

(env) g:\laragonServerPortable\www\f28gallery>where python.exe
g:\laragonServerPortable\www\f28gallery\env\Scripts\python.exe
C:\Program Files\Python312\python.exe

(env) g:\laragonServerPortable\www\f28gallery>where pip3.exe
g:\laragonServerPortable\www\f28gallery\env\Scripts\pip3.exe
C:\Program Files\Python312\Scripts\pip3.exe

(env) g:\laragonServerPortable\www\f28gallery>

So far so good. I will now run the pip3 command to install into venv.

(env) g:\laragonServerPortable\www\f28gallery>pip3 install -r requirements.txt
Collecting Jinja2==3.1.4 (from -r requirements.txt (line 1))
  Using cached jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)
Collecting Pillow==10.4.0 (from -r requirements.txt (line 2))
  Using cached pillow-10.4.0-cp312-cp312-win_amd64.whl.metadata (9.3 kB)
Collecting MarkupSafe>=2.0 (from Jinja2==3.1.4->-r requirements.txt (line 1))
  Using cached MarkupSafe-2.1.5-cp312-cp312-win_amd64.whl.metadata (3.1 kB)
Using cached jinja2-3.1.4-py3-none-any.whl (133 kB)
Using cached pillow-10.4.0-cp312-cp312-win_amd64.whl (2.6 MB)
Using cached MarkupSafe-2.1.5-cp312-cp312-win_amd64.whl (17 kB)
Installing collected packages: Pillow, MarkupSafe, Jinja2
Successfully installed Jinja2-3.1.4 MarkupSafe-2.1.5 Pillow-10.4.0

(env) g:\laragonServerPortable\www\f28gallery>

Looks good, no errors. I will now run the main gallery generator

(env) g:\laragonServerPortable\www\f28gallery>f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output
Traceback (most recent call last):
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 10, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

(env) g:\laragonServerPortable\www\f28gallery>

Nope. Not working. Why? Is my Gallery folder in the wrong place? I put it in the f28gallery folder beside f2.8gallery.py.

I will check my path -

(env) g:\laragonServerPortable\www\f28gallery>path
PATH=g:\laragonServerPortable\www\f28gallery\env\Scripts;C:\Program Files\Python312\Scripts\;C:\Program Files\Python312\;g:\-----New After May 4 2020\TonysAppz\MapTiler Engine;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;c:\Users\pt\AppData\Roaming\Microsoft\Windows\SendTo\;G:\-----New After May 4 2020\TonysAppz\NVEncC64;C:\go\bin;C:\Program Files\Git\cmd;C:\Users\pt\AppData\Local\Microsoft\WindowsApps;C:\Users\pt\go\bin

(env) g:\laragonServerPortable\www\f28gallery>

Looks good, env path is first. Hmm.......

Here is my env\lib\site-packages folder contents -

folderContents

Should the Pil folder be named Pillow instead of Pil??

asmartin commented 3 days ago

Thanks for the detailed debug data! I see the issue - Windows uses a case-insensitive filesystem and the PIL dependency is getting installed as Pil instead. I added code in this PR to account for this situation; can you give that version a try and confirm it works?

tyeeman commented 3 days ago

Thanks. Sorry I'm not that skilled on git. How do I get the new file with the changes?

asmartin commented 3 days ago

Click here and replace the entire contents of the existing f2.8gallery.py file with that file and then give it a try.

tyeeman commented 3 days ago

Ok, I replaced the file and ran it -

(env) g:\laragonServerPortable\www\f28gallery>f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output
Traceback (most recent call last):
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 16, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 19, in <module>
    from Pil import Image
ModuleNotFoundError: No module named 'Pil'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 21, in <module>
    from pil import Image
ModuleNotFoundError: No module named 'pil'

Looks like something else is happening. Would the "shebang" line in f2.8gallery.py have anything to do with this? The docs say any script installed in a venv will have the full path to the python venv executable as the shebang line. In this case the f2.8gallery.py file is not actually installed. It's just run after the venv is set up. So I'm thinking that may have something to do with this? My shebang line is the Linux version, not a Windows version.

asmartin commented 3 days ago

Hm... that error indicates that PIL can't be found, even though we saw it in your screenshot of env\lib\site-packages above. Can you paste the contents of env\lib\site-packages\Pil to see if it's just an empty directory or actually contains the contents of the package?

The shebang is a good idea. You could try replacing it with #!/usr/bin/env python or #!/usr/bin/python (not python3) and see if that has any effect.

Or, execute the script with python directly from within the virtualenv:

(env) g:\laragonServerPortable\www\f28gallery>python f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output

Another option would be to try launching this using Windows Subsystem for Linux (e.g. with the Ubuntu 24.04 distribution); this feature is included with Windows and would execute the program in a native Linux environment

tyeeman commented 2 days ago

Well, I'm getting closer - the python docs say I can run a .py file without activating the venv by running the python.exe from within the venv, so here it is -

g:\laragonServerPortable\www\f28gallery>"G:\laragonServerPortable\www\f28gallery\env\Scripts\python.exe" f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output
generating thumbnails
Traceback (most recent call last):
  File "g:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 193, in <module>
    main()
  File "g:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 119, in main
    create_if_not_exists(thumbnail_dir)
  File "g:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 31, in create_if_not_exists
    os.mkdir(path=dir, mode=0o755)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'output/thumbnails/galleries\\1_tony'

Nothing about Pil anymore, trying to create thumbnails. Looks like a backslash (windows), frontslash (linux) problem.

Try 2 OK. I got the identical error as above when I replaced the shebang line of f2.8gallery.py with the path to the venv python.exe and then just ran f2.8gallery.py as shown here -

shebang line -

#!"env\Scripts\python.exe"
g:\laragonServerPortable\www\f28gallery>f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output
generating thumbnails
Traceback (most recent call last):
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 193, in <module>
    main()
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 119, in main
    create_if_not_exists(thumbnail_dir)
  File "G:\laragonServerPortable\www\f28gallery\f2.8gallery.py", line 31, in create_if_not_exists
    os.mkdir(path=dir, mode=0o755)
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'output/thumbnails/galleries\\1_tony'

So, yes, getting very close. Just need those slashes fixed I guess. That still doesn't explain why yesterday my activated venv gave us those Pil errors! Hmmm.....Right now if I change the shebang line back to the linux one I get the Pil errors again.

asmartin commented 2 days ago

Try running this version, which should have better portability support for navigating the filesystem.

Also trying calling it via python f2.8gallery.py once the venv is activated again - I updated the shebang so I think it should now work without needing to specify the full path to python.exe.

tyeeman commented 2 days ago

OK, It works! Thanks.

After activating venv, I ran f2.8gallery.py --title "John Smith Photos" --author "John Smith" galleries output and I got the Pil errors again.

I had to add python to the start of the command line like you mentioned above. Why? Aren't .py files associated with the python.exe?

asmartin commented 2 days ago

Glad to hear it's working! I'm not sure why invoking it with python is required on Windows (I'm not very familiar with cross-platform compatibility issues) but if that works I'll update the instructions to invoke it that way for portability

tyeeman commented 2 days ago

Thanks for all your help. I'm thinking a windows .py file is associated with the non venv python.exe, so to use the venv python.exe it must be specified on the command line while the venv is active.

tyeeman commented 2 days ago

One last question - how to shift the thumbnails at the bottom of the screen fully off screen when not desired?

asmartin commented 2 days ago

Can you post a screenshot illustrating what you're asking for? I'm not sure I understand exactly what you mean

tyeeman commented 1 day ago

2024-09-16_195315_cr

Or maybe something simpler or different?

asmartin commented 1 day ago

The following changes to index.j2 will hide those parts of the interface:

@@ -47,9 +47,9 @@
             "display":    false
           },
           "viewerTools":     {
-            "topLeft":    "pageCounter, playPauseButton, shareButton",
-            "topRight":   "zoomButton, fullscreenButton, closeButton"
+            "topRight":   "closeButton"
           },
+         "viewerGallery": "none",
           "galleryTheme": "dark",
           "viewerTheme":  "dark",
           "thumbnailWidth": "{{ thumbwidth }}",

I don't think there's a way to toggle them dynamically on-the-fly, but see here for the upstream documentation with more details

tyeeman commented 1 day ago

Oh, maybe I'm not clear. Just remove the bottom small images in the horizontal row, not anything currently in the top right or top left. I think that's viewerGallery. I see it can be set to "bottom". Yes, that's what I was wanting.

asmartin commented 1 day ago

In that case just add "viewerGallery": "none", and don't change those other lines