Closed gingerbeardman closed 1 month ago
Thank you for sharing your installation experience. Glad that using pipx worked smoothly for you.
The problems you encountered when installing with pip are likely due to the specific Python environment on your system rather than an issue with pip itself (or with pooltool). On macOS, the system Python can have restrictions or conflicts because it's managed by the operating system, which can lead to missing libraries or other problems when installing packages globally.
Using pipx helps in this case because it installs Python applications in isolated environments, avoiding conflicts with the system Python. Similarly, using pip within a virtual environment can also prevent these issues by creating an isolated space for package installations. However, since pooltool is as much a python package as it is an application, installing with pipx would be inadvisable for many of its use cases.
Understood.
Advice how to proceed or resolve macOS issues with pip would be appreciated.
Sure. You want to separate your business with virtual python environments, i.e. environments that are separate from each other and from the system-level python that mac has. The most canonical options are venv and conda. Here is a shameless copy-paste GPT4o response on getting started with either:
Here are two options for creating virtual Python environments, using both venv
and conda
:
venv
(Built-in Python Tool)venv
is a built-in Python module that comes with Python 3.3 and later. It allows you to create lightweight virtual environments where each environment has its own isolated Python interpreter and set of libraries.
Install Python: Ensure that you have Python installed. You can check by running:
python --version
If Python isn't installed, download and install it from the official Python website.
Create a virtual environment:
python -m venv myenv
This creates a folder named myenv
with a copy of the Python interpreter and a blank environment.
Activate the virtual environment:
myenv\Scripts\activate
source myenv/bin/activate
Install dependencies: Once the environment is active, you can install Python packages using pip
:
pip install package_name
Deactivate the environment: To exit the virtual environment, simply run:
deactivate
conda
(Anaconda/Miniconda Environment Manager)conda
is a package and environment manager that works not only for Python but also for other languages like R. It allows you to create isolated environments with specific versions of Python and libraries.
Install Conda:
Create a conda environment:
conda create --name myenv python=3.x
Replace 3.x
with the Python version you want to use. This will set up an environment named myenv
.
Activate the conda environment:
conda activate myenv
Install dependencies:
conda
or pip
:
conda install package_name
or
pip install package_name
Deactivate the environment:
conda deactivate
Remove the environment (Optional):
conda remove --name myenv --all
Both venv
and conda
provide isolated environments, but conda
is more powerful for managing dependencies and cross-language packages. venv
is simpler and comes with Python by default, making it a good option for smaller projects or when you only need Python-specific libraries.
EDIT I also have a tip: when you make a virtual environment, you should verify the pip you're using is the pip associated with your new environment with which pip
. This should yield a different path than if you run which pip
outside your virtual environment.
I appreciate that those are the recommended ways to do it. But, wow that's a lot of busy work for gains I will never, ever see.
So, honestly, I'll just stick to pipx pooltool
literally two words.
Of course, I don't use pooltool as a framework I just play it as a game.
My advice is unrelated to pooltool and is more about improving computational literacy around the Python ecosystem. Being able to spin up python virtual environments is not a skill you will regret having.
Bringing this back to pooltool, it would be great to have a "double click to install" option that drew in less computational folk. I notice you've made a Stapler app. Not to put you on the spot, but do you think you would be able to create a macOS package installer for pooltool? I have no idea how any of that stuff works. Is that something you have the bandwidth for?
Until then, I concur pipx
is not a bad solution.
For Python + Qt apps I've created (I use venv there) I used pyinstaller to build an app from my code.
Here's the shell command I arrived at to generate the spec file
pyinstaller -y --onedir --windowed --osx-bundle-identifier com.gingerbeardman.beatbox --name Beatbox --icon "icon.icns" gui.py
then it's easy to build from the spec for every subsequent change
#!/usr/bin/env zsh
pyinstaller -y Beatbox.spec
echo "Removing old app..."
rm -rf /Applications/Beatbox.app
echo "Installing new app..."
mv ./dist/Beatbox.app /Applications/Beatbox.app
open /Applications/Beatbox.app
my requirements.txt
PyQt6
numpy
matplotlib
sounddevice
configparser
pyinstaller
pyinstaller_versionfile
Once you have the self-contained app file, it's easy to generate an installer .pkg (for wizard installing) or a disk image .dmg (for drag and drop installing)
I installed using pipx and it just worked.
I couldn't get it to run after installing with pip, missing libraries and other problems.
IIRC Apple have locked some of the system python down so it's no longer advised to install using pip.
AFAIK pipx is recommended for installing apps, pip for frameworks
I'm not an expert :)