pyenv on Mojave throwing undeclared identifier 'CLOCK_REALTIME' and other errors when installing 3.5.6, 3.6.7
Asked Answered
H

2

6

I'm trying to install various versions of python3 on macOS Mojave 10.14.2 Beta (18C52a).

3.6.7 fails with:

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.6.7.tar.xz...
-> https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tar.xz
Installing Python-3.6.7...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.14.2 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115752.83999
Results logged to /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115752.83999.log

Last 10 log lines:
./Include/pytime.h:200:52: warning: declaration of 'struct tm' will not be visible outside of this function [-Wvisibility]
PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
                                                   ^
./Include/pytime.h:204:49: warning: declaration of 'struct tm' will not be visible outside of this function [-Wvisibility]
PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
                                                ^
2 warnings generated.
2 warnings generated.
2 warnings generated.
2 warnings generated.

3.5.6 fails with:

python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.5.6.tar.xz...
-> https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tar.xz
Installing Python-3.5.6...
python-build: use readline from homebrew

BUILD FAILED (OS X 10.14.2 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115931.92145
Results logged to /var/folders/db/pjnyydt54kl3_snfwpvlsxf40000gp/T/python-build.20181204115931.92145.log

Last 10 log lines:
Python/pytime.c:508:13: warning: implicit declaration of function 'clock_getres' is invalid in C99 [-Wimplicit-function-declaration]
        if (clock_getres(CLOCK_REALTIME, &res) == 0)
            ^
Python/pytime.c:508:13: warning: this function declaration is not a prototype [-Wstrict-prototypes]
Python/pytime.c:508:26: error: use of undeclared identifier 'CLOCK_REALTIME'
        if (clock_getres(CLOCK_REALTIME, &res) == 0)
                         ^
4 warnings and 2 errors generated.
make: *** [Python/pytime.o] Error 1
make: *** Waiting for unfinished jobs....

I've tried, through brew:

  1. Reinstalling all of pyenv, python, python3, xz, readline, openssl (per this answer)
  2. I've tried installing and reinstalling the macOS developer tools
  3. I've tried sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target / (per the pyenv docs)
  4. I tried this on a new build of Mojave running 10.14.1 (18B75), and I get the same problem.

Oh, and darn, I’m using Fish. I’ll have to look and see if this is a Fish-specific problem πŸ€”πŸ  (Update: no, it's not Fish, it happens in a standard /bin/sh)

Holder answered 4/12, 2018 at 20:7 Comment(8)
Did you try install pyenv from source, via Github to see if that works? github.com/pyenv/pyenv#basic-github-checkout . Also do you have the most up to date version of gcc & xcode installed? – Oneiric
Have not tried building from source, I’ll give it a shot. Also better double check which Xcode version is active... good call. – Holder
No worries, keep me in the loop, want to see how this turns out :) – Oneiric
Not a specific solution to your problem; I had the same issue when trying to install python 2, I worked around it by installing a version of miniconda2. – Valiant
Could you post the complete log file please? – Party
I think we're onto something here with fish, but even then I'm not totally sure. I can't even get it to work with fish's goofy non-standard path/syntax variables, but even then, if others are having the problem too... – Holder
And now, I just tried it with asdf, and the same error occurs. – Holder
@Party pastebin.com/4W5nr8tJ – Holder
C
0

If you would and to maintain different versions of python, asdf is a good option. You could use the following steps to install.

git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.6.2

And since you seem to using fish you could do the following

echo 'source ~/.asdf/asdf.fish' >> ~/.config/fish/config.fish
mkdir -p ~/.config/fish/completions; and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions

At this point you would want relaunch your terminal for the asdf to take effect. One mac OS you might need to homebrew install coreutils automake autoconf openssl libyaml readline libxslt libtool unixodbc, as some the plugin might need them.

Then you are now set to install python plugin. First need to pull it it.

asdf plugin-add python

Once you have the plugin installed it is time to install your needed versions.

asdf install python 3.5.6
asdf install python 3.6.7

Once they are intalled successfully, you could switch between them using

asdf global python <version-of-your-choice: eg. 3.5.6>

eg. asdf global python 3.5.6

I hope this helps.

Cyrenaic answered 13/12, 2018 at 4:1 Comment(1)
There seem to issues reported on this, here and here – Cyrenaic
E
0

I don't know if this was the problem, but I ran into a similar error when I was trying to install a number of pip packages that had a build step which relied on time.h. The problem was that I had a stray one deficient in the necessary exports inside /usr/local/include. If you're (mis)using brew, you might have a number of redundant, out of date, and conflicting headers/libs linked in /usr/local/*. I suggest getting a verbose output, find the exact build command that produces the error, look at each -I flag, and search recursively for time.h. My bet is that one of them is some relic you want to get rid of.

Excide answered 27/2, 2020 at 17:52 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.