At first, attempting pip install groupdocs-viewer-net
was yielding an error that said no such file existed, despite me getting that command off of groupdocs-viewer-net · PyPI. So I proceeded to download groupdocs_viewer_net-24.9-py3-none-macosx_11_0_arm64.whl (160.0 MB view details)
from the same PyPI website and added to my root directory to install it directory. There appears to be the following issue (copy pasted from claude):
Looking at the contents of the wheel file, I can see a significant issue. The wheel naming convention indicates it’s built for Python 3 on macOS 11.0 for arm64 architecture, but there’s a mismatch in the compatibility information.
The issue is actually visible in the binaries included in the wheel:
It contains .so files for Python 3.9, 3.10, and 3.11 (note the cpython-39-darwin.so, cpython-310-darwin.so, and cpython-311-darwin.so files)
There are no .so files for Python 3.12 or 3.13
The error message is confusing because it states:
requires a different Python: 3.13.2 not in '<3.12,>=3.9'
This means the package claims to be compatible with Python versions 3.9 to 3.11 (>=3.9 but <3.12), but you’re trying to install it with Python 3.13.2.
Here are your options:
- Create a virtual environment with Python 3.11 (the latest supported version):
Anyhow, so at this point i create a venv and set pyenv to 3.11.8 and now I can finally install groupdocs viewer…
My issue now is that I don’t know how to use my free temporary license to:
- Create a test implementation in python
- Create a react component that displays pptx files and refreshes it upon command for my JS front end script
I can’t seem to find my way around the docs to actually start using GroupDocs. I can’t seem to find a way to even import the module into any of my python scripts.
I would really appreciate any help from anyone with getting a viewer created in both python and JS.
-AH
@azizhayat
Can you please specify which specific functionalities you are trying to implement with the GroupDocs viewer in Python and React? Additionally, could you clarify how you are attempting to import the module into your Python scripts?
i am trying to import the dependency as groupdocs-viewer-net (as it appears in my requirements.txt) but it seems it isn’t being recognized. I also tried import groupdocs.viewer as gv and variations of that, but still no use.
I have powerpoint files (.pptx) being stored in DigitalOcean Spaces that I need displayed within a react component on my frontend, but i’m just trying to get it to work in general with python in a separate script right now.
@azizhayat
Thank you for the details that you have shared. There are a couple of issues here that I can see, so let’s handle them one by one.
Check if requirements are met
To run groupdocs-viewer-net package on macOS you need:
- ARM64 CPU (M1, M2, etc.)
- Python version >= 3.9 and <=3.12
- .NET 6.0 runtime or above for macOS.
Run the sample app
Follow these steps to set up and run GroupDocs.Viewer for Python via .NET on macOS.
-
Create a Virtual Environment
Run the following command to create a virtual environment:
python3 -m venv .venv
-
Activate the Virtual Environment
Activate the virtual environment using:
source .venv/bin/activate
-
Create a requirements.txt
File
Create a requirements.txt
file with the following content:
groupdocs-viewer-net==24.9
-
Install Dependencies
Run the following command to install the required dependencies:
python3 -m pip install -r requirements.txt
-
Create the app.py
File
Create a file named app.py
and add the following content:
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions
def render_docx():
with Viewer("sample.docx") as viewer:
options = HtmlViewOptions.for_embedded_resources("page_{0}.html")
viewer.view(options)
if __name__ == "__main__":
render_docx()
-
Copy sample.docx
to the Current Directory
Ensure that sample.docx
is present in the same directory as app.py
.
-
Run the Application
Execute the following command to run the script:
python3 app.py
As a result, you will get two HTML files in the current directory.
-
Deactivate the Virtual Environment (Optional)
When finished, you can deactivate the virtual environment by running:
deactivate
Alternatively, you can simply close the terminal.
I have also pushed this sample application to GitHub: hello-world-macos app.
Summary
The steps above should help you to get started with GroupDocs.Viewer on macOS. Please let us know if you have any further issues or questions.
@vladimir.litvinchik
Context: I’m working with VS Code on an M1 Macbook Pro, Python 3.11.8 via pyenv, and .NET 9.0 runtime for Mac OS.
I’ve gotten the sample script you’ve given me to work, but I need your help getting the following sample code from https://docs.groupdocs.com/viewer/python-net/render-presentations/
to work, specifically:
with gv.Viewer("sample.pptx") as viewer:
# Create a PNG image for each slide.
# {0} is replaced with the current page number in the image name.
viewOptions = gvo.PngViewOptions("output_{0}.png")
viewer.view(viewOptions)
Below is the code currently in my editor:
# This example demonstrates how to render a document into a PNG image.
from groupdocs.viewer import Viewer
from groupdocs.viewer.options import HtmlViewOptions, PngViewOptions
docx_path = "sample.docx"
pptx_path = "deck_76.pptx"
def render_docx():
with Viewer(docx_path) as viewer:
options = HtmlViewOptions.for_embedded_resources("page_{0}.html")
viewer.view(options)
def render_pptx():
with Viewer(pptx_path) as viewer:
# Create a PNG image for each slide.
# {0} is replaced with the current page number in the image name.
viewOptions = PngViewOptions("output_{0}.png")
viewer.view(viewOptions)
if __name__ == "__main__":
# Pick which one you want to render
#render_docx()
render_pptx()
I noticed in your docx sample script that ‘gv’ and ‘gvo’ are not referenced unlike the sample from the website given below:
with gv.Viewer("resume.docx") as viewer:
# Create an HTML files.
# {0} is replaced with the current page number in the file name.
viewOptions = gvo.HtmlViewOptions.for_embedded_resources("page_{0}.html")
viewer.view(viewOptions)
When I run my script to test the PPTX to PNG conversion (omitting gv and gvo as we’ve done for the docx conversion code), I get the following error:
RuntimeError: Proxy error(GroupDocsViewerException): The type initializer for 'Gdip' threw an exception. (TypeInitializationException)
Any help getting pptx to png conversion to work would be highly appreciated.
Regards,
-AH
UPDATE
The issue was fixed with:
brew install mono-libgdiplus
@azizhayat
Thank you for the feedback. Yes, libgdiplus
is required. When I was running the application on my Mac the dependency was already installed, so I have missed this part. I believe that this requirement should be also reflected in the documentation.
Let us know if you have any other questions.
1 Like