BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
I need some help compiling/building some Mac software on GitHub.
I have tried my best (NOT a Command Line guy) but the build script fails after installing all the dependencies.
It is very specialized software and development has ended (developer not reachable)...but I need a working copy!

I have managed to build the Linux version but I really need to have this on my Macbook Pro to be productive.

The software I need to build is here:
https://github.com/PeachyPrinter/peachyprinter

It is dependent on Kivy version 1.9.0.
Maybe a newer version will work... I'm not sure.
[A reply on the Kivy forum says that the newest version *should* work]

The build scripts point to Kivy/MASTER but 1.9.0 is not the "Master" anymore.
Version 1.9.0 is here:
https://github.com/kivy/kivy/tree/stable-1.9.0


I really hope someone out there can help !!
I'm totally stuck !!

Thanks!
Jason
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
Didn't try to compile it myself, but is homebrew installed on your Mac and did you try to comment out line 4 to 7 of build_mac.sh in peachyprinter repository?
 

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
@organicCPU I have homebrew installed and those lines were not commented out by me. I assume the dev commented them out as he already had the dependencies installed. I activated those lines so they could be installed.
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
Yes, uncommenting line 4 up to 7 is what I meant (delete the comment signs ##). You still get (the same) errors? If yes post the errors (Terminal output) and your version of macOS, like @kryten2 asked before!
 

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
Here is exactly what I did and the errors that occur:


Install home brew
-used script line from https://brew.sh
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Following instructions in the ReadMe doc to setup the python environment.
pip install virtualenv

This did not work...
-bash: pip: command not found

Ran the build script
./build_mac.sh

Dependancies installed, then script FAILED...
------------------------------------
Setting up Enviroment
------------------------------------
/usr/bin/python: No module named virtualenv
./build_mac.sh: line 32: venv/bin/activate: No such file or directory
FAILURE: Creating Virtual env

Trying... (because I saw a reference to installing python with pip2 while the dependancies were installing)
pip2 install virtualenv
***WORKED***
Collecting virtualenv
Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 645kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0

Commented out dependencies in build_mac.sh and reran it
This FAILED...
------------------------------------
Setting up Enviroment
------------------------------------
/usr/bin/python: No module named virtualenv
./build_mac.sh: line 32: venv/bin/activate: No such file or directory
FAILURE: Creating Virtual env
[doublepost=1512152827][/doublepost]I'm using Mac OS High Sierra 10.13.1
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I don't know Python very well, but I think, a misconfigured Python setup is the problem we see here.
Try running those two commands and post the python version number in use:
Code:
which -a python
python -V
The first command shows every installed Python binary on your Mac and the second one the recent active Python version. As you need to deal with virtualenv, maybe someone else has ideas, as I just use pyenv, not virtualenv.

What I can see is, you should have installed another version of Python with brew by uncommenting the lines, but your system Python in /usr/bin/python is in use, not the one of your brew install that is linked under /usr/local/bin. Usually your ~/.bash_profile should contain the path to the Python, you use. If you close the Terminal session and open a new one, is the error the same? If yes, at least your .bash_profile isn't up to date. Look up, how to configure it right with virtualenv with something like this (maybe a virtualenv user can provide more capable help):
Code:
export VIRTUALENV_ROOT="/path/to/python"
export PATH="$VIRTUALENV_ROOT/bin:$PATH"
 

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
which -a python
/usr/bin/python

python -V
Python 2.7.10

Closed the terminal and opened a new one.
Ran the build script again, same error.

I looked in /usr/bin/ and there is no python directory.
This were files named:
python
python-config
python2.7
python2.7-config

Opening the python2.7-config file showed this in the first line:
#!/System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

I looked at .bash_profile and there was NOTHING pointing to python at all.
So I tried separately adding:
export PATH="/usr/bin/python"
export PATH="/usr/bin/python2.7"

I added each one separately then reran the build script each time.
Same error as before for both.
 
Last edited:

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
PIP seems to be significant point of failure.

pip --version
Gives me a "command not found" error but...

pip2 --version
Gives me: "pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python 2.7)"

There are two lines in the build script that use "pip".
I changed them to pip2 and tried again.

This failed with the error:
/usr/bin/python: no module named pip2
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I looked at .bash_profile and there was NOTHING pointing to python at all.
So I tried separately adding:
export PATH="/usr/bin/python"
export PATH="/usr/bin/python2.7"
You don't need to add these PATHs in your .bash_profile, because /usr/bin/ is already included. Just delete them.

Instead add this to your .bash_profile (see-> brew info python)
Code:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"

We need to find out, where pip2 is installed (which pip2 -> works just after next step or restart Terminal session) and make an alias, to get the pip command working, add something like this to your .bash_profile
Code:
alias pip="/usr/local/lib/python2.7/site-packages/pip2"
Alternatively you could just use pip2 instead of pip.

To activate the changes in .bash_profile without restarting the terminal session, we can type this command:
Code:
source ~/.bash_profile

We should comment out the lines 4 to 7 in build_mac.sh again by adding ## at the beginning of the lines.

Then try again
 
Last edited:

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
I think I solved it !!!

I changed "python" in lines 7, 29 & 43 to "python2.7" and it's actually doing stuff !!
I'll let know know if it works...
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I changed "python" in lines 7, 29 & 43 to "python2.7" and it's actually doing stuff !
I hope this won't break your preinstalled Python. Changing the PATH to point to your brew installed Python, like described in my last post would have been a better idea, IMHO. But let us know how things are doing.
 

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
Ok failed when "Removing temp files" while "Building package".
That means it got to line 82 in the build script.

When "Removing Temp files" it did a Traceback and at the end of that list of fiels it staes:
ImportError: No module named kivy.tools.packaging.pyinstaller_hooks
FAILURE: Building app


I will make teh changes you suggested
[doublepost=1512169635][/doublepost]I changed the .bash_profile with the items you suggested.
I looked in /usr/local/lib/python2.7/site-packages/ and found "pip" there, but no "pip2"
[doublepost=1512170003][/doublepost]
export VIRTUALENV_ROOT="/path/to/python" export PATH="$VIRTUALENV_ROOT/bin:$PATH"

I didn't add these because I didn't understand them.
I'm still not exactly sure what the proper path to python is
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I didn't add these because I didn't understand them.
Yes, do not use those lines in .bash_profile. It was my mistake to bring that confusingly in.
I'm still not exactly sure what the proper path to python is
The proper path to your preinstalled Python 2.7.10 is just /usr/bin
The proper path to your homebrew installed Python 2.7.14 should be /usr/local/opt/python/libexec/bin as you declared with
Code:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Remember, changes of .bash_profile will only take affect, if you start a new session or use the source command or equivalent.
You can check if the path is correct with 'which python' and 'python -V' commands

To explain the former two liner of post #7, you could write the above export path in two lines like this:
Code:
export PATH_TO_PYTHON="/usr/local/opt/python/libexec"
export PATH="$PATH_TO_PYTHON/bin:$PATH"
Thats just another way of writing
Code:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Sometimes, especially in large .bash_profile files it's just a more comprehensive view to declare a variable (like PATH_TO_PYTHON or VIRTUALENV_ROOT) first and then call that variable in another line.

With :$PATH you then assign all existing values of PATH to itself, means add all other existing PATH declarations to the variable PATH to be still able to execute all installed binaries.
: is the Separator of different PATHs
$PATH calls your Path variable
To get your whole PATH variable printed at the command line, execute
Code:
echo $PATH

However, did you have more luck with installing peachyprinter or are you still getting the error from the last post?
[doublepost=1512174945][/doublepost]
I looked in /usr/local/lib/python2.7/site-packages/ and found "pip" there, but no "pip2"
Then the alias could be written:
EDIT:
Code:
alias pip="/usr/local/lib/python2.7/site-packages/pip"
SHOULD BE:
Code:
alias pip="/usr/local/Cellar/python/2.7.14/libexec/bin/pip"

I guess in /usr/local/bin the symlink is called pip2, otherwise you'd be able to execute pip. If you make a symlink in /usr/local/bin or an alias in .bash_profile doesn't make so much difference here.
To get contents of /usr/local/bin listed:
Code:
ls -al /usr/local/bin
 
Last edited:

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
If you get the errors from post #13 we got to the file peachyprinter-mac.spec.source. I'm not sure what the developer wrote, because I don't know python very well, but I guess you'd need a working kivy installation, to get peachyprinter-mac.spec.source executed.
Just want to check if everything is configured correctly before:
Code:
python -V
should output Python 2.7.14
Code:
pip -V
should output something like pip 9.0.1

If that's correct, we can proceed installing kivy.
As we already should have sdl2, sdl2_image, sdl2_ttf and sdl2_mixer installed during the first build_mac.sh run with uncommented Mac Setup, I guess we won't need to run
Code:
brew install pkg-config sdl2 sdl2_image sdl2_ttf sdl2_mixer gstreamer
To get just pkg-config and gstreamer we try just running
Code:
brew install pkg-config gstreamer
Then we need those two
Code:
pip install Cython==0.26.1
Code:
pip install kivy

And try again.
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
Just reread the build_mac.sh and discovered the use of pyinstaller in line 83.
Check if you have pyinstaller already installed by
Code:
pyinstaller --version
if that outputs 'command not found', you should probably install pyinstaller by executing
Code:
pip install pyinstaller
 

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
I does seem to fail with pyinstaller...
I checked the pyinstaller version:
-bash: pyinstaller: command not found

I tried installing pyinstaller:
-bash: /usr/local/lib/python2.7/site-packages/pip: is a directory
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I tried installing pyinstaller:
-bash: /usr/local/lib/python2.7/site-packages/pip: is a directory
It seems the Alias in #14 is pointing to the directory where pip is installing packages to and not to pip itself. Sorry, my mistake, corrected in post #14. You should have seen the problem with 'pip -V', didn't you?
Enter:
Code:
which pip2
pip2 should be just a symlink to the pip command of the python version, we're using (2.7.14).
Once we know, where to find the right pip command we need to modify the Alias for pip in .bash_profile accordingly.
Should be something like this:
Code:
alias pip="/usr/local/Cellar/python/2.7.14/libexec/bin/pip"
Be aware that this setup is not the recommended way to handle multiple Python installs, but hopefully it should lead to some success with installing peachyprinter without going into the details of pyenv or virtualenv.
As mentioned before, alternatively you could just use pip2 instead of pip and don't make an Alias at all. As build_mac.sh is using the pip command in line 43, we would then need to modify this to pip2.

Then try again
 
Last edited:

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
I updated the alias as described above and ran the build script again.
Failed. Looks the same as before. Here is some of the final output...


-----------------------------------
Enviroment setup complete and seemingly successful.
You are using pip version 6.0.8, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting setuptools==19.2
Using cached setuptools-19.2-py2.py3-none-any.whl
Installing collected packages: setuptools
Found existing installation: setuptools 38.2.3
Uninstalling setuptools-38.2.3:
Successfully uninstalled setuptools-38.2.3

Successfully installed setuptools-19.2
------------------------------------
Extracting Git Revision Number
------------------------------------
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Version: 1.1.1.0
Git Revision Number is 0
------------------------------------
Building Package
------------------------------------
26 INFO: PyInstaller: 3.1
26 INFO: Python: 2.7.14
32 INFO: Platform: Darwin-17.2.0-x86_64-i386-64bit
39 INFO: UPX is not available.
39 INFO: Removing temporary files and cleaning cache in /Users/dac/Library/Application Support/pyinstaller
Traceback (most recent call last):
File "/Users/dac/Desktop/peachyprinter-master/venv/bin/pyinstaller", line 11, in <module>
load_entry_point('PyInstaller==3.1', 'console_scripts', 'pyinstaller')()
File "/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller/__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller/__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 755, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller/building/build_main.py", line 701, in build
exec(text, spec_namespace)
File "<string>", line 5, in <module>
ImportError: No module named kivy.tools.packaging.pyinstaller_hooks
FAILURE: Building app
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
Actually I don't know where pip 6.0.8 is coming from.
Post the output of
Code:
which pip; which pip2
Modify line 43 of build_mac.sh to
EDIT: probably unwanted and unnecessary
Code:
python -m pip2 install --upgrade setuptools==38.2.3

Try again
 
Last edited:

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
Rereading your output makes clear that virtualenv succeeded in creating a virtual python environment.
I guess pip 6.0.8 is the pip version installed inside your virtual python environment.
As it should only target your active virtual python environment, modifying line 43 of build_mac.sh in the way I recommended in my last post, probably isn't necessary or wanted and you can revert it back to original, because the peachyprinter developer might have had some reasons to downgrade it:
Code:
python -m pip install --upgrade setuptools==19.2

ImportError: No module named kivy.tools.packaging.pyinstaller_hooks
At this point it seems that inside the created virtual python environment the pyinstaller command is unable to locate a file called kivy-hook.py or is catching a wrong one. I can imagine that there is an easy fix for this.

As a blind guess one of those solutions could provide a fix, although I'm not sure if those would work nor breaking something else.

in peachyprinter-mac.spec.source add this to line 3:
import kivy

or modify line 16 in peachyprinter-mac.spec.source to:
hookspath=[/path/to/where/kivy-hook.py/resides],
where you need to substitute /path/to/where/kivy-hook.py/resides by the actual path to to the directory of kivy-hook.py that probably is somewhere inside your 'venv' folder in your root directory.

or give virtualenv access to your dependencies outside the virtual environment to get kivy-hook.py from the kivy installation that you made with the last command of post #16. This could work by modifying line 29 of build_mac.sh:
python -m virtualenv --system-site-packages venv

As I know too less or better absolute nothing about kivy and virtualenv it would help you much more if an experienced Python developer could jump in here to give you better advice how to fix this. It always helps, if you post about your progress.
 
Last edited:

BilduKat

macrumors newbie
Original poster
Apr 19, 2005
20
0
Dac:~ dac$ which pip
/usr/local/opt/python/libexec/bin/pip
Dac:~ dac$ which pip2
/usr/local/bin/pip2

I'll post this for now while I read through your last post.
Thank you for your continued support on this! I truly appreciate it!
[doublepost=1512333717][/doublepost]I've added "import kivy" to line 3 as you suggested.

in the build_mac.sh file I modified line 29 to:
python -m virtualenv --system-site-packages venv

Build fails in same way.


I did some searching and found "hooks_kivy.py" in the directory below.
/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller

That file contains the reference that ends the build:
if is_module_satisfies('kivy >= 1.9.1'):
from kivy.tools.packaging.pyinstaller_hooks import (
add_dep_paths, excludedimports, datas, get_deps_all,
get_factory_modules, kivy_modules)


I've tried to find "kivy.tools.packaging.pyinstaller_hooks" but I'm starting to think that it is not a file.
 

organicCPU

macrumors 6502a
Aug 8, 2016
706
199
I did some searching and found "hooks_kivy.py" in the directory below.
/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller
Then I suggest modifying line 16 in peachyprinter-mac.spec.source to:
Code:
hookspath=[/Users/dac/Desktop/peachyprinter-master/venv/lib/python2.7/site-packages/PyInstaller],
I've tried to find "kivy.tools.packaging.pyinstaller_hooks" but I'm starting to think that it is not a file.
You're right, it's not a file. AFAIK there is just kivy.tools that is the tools module of kivy and one part of it are hooks for pyinstaller. If the above change of the hookspath doesn't work, you could read more about when things go wrong with pyinstaller, the kivy environment and virtualenv. The solution should be somewhere in the linked docs, but I can't find it.

I guess there is some setup wrong inside the virtual python environment (probably with the kivy environment setup or the pyinstaller configuration) created by the installer script, so that pyinstaller can't locate hooks_kivy.py or kivy. For windows there is a .bat file that should correct the issue, but on a Mac for that purpose there should just be some main.py file that should be configurable and might be in your /Users/dac/Desktop/peachyprinter-master/venv/ folder, too.
However, you could also try modifying the script to fetch and install the more recent kivy 1.10 and not 1.9.1, then even replace the other outdated dependencies, that are a lot. If that could lead to another output, I don't know, because the initial problem seems to configuration at this point.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.