Python 3.9.12 build failed - generate-posix-vars failed - python

New to python. Trying to install 3.9.12 via pyenv. Getting the following error:
pyenv install 3.9.12
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.12.tar.xz...
-> https://www.python.org/ftp/python/3.9.12/Python-3.9.12.tar.xz
Installing Python-3.9.12...
python-build: use tcl-tk from homebrew
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 12.6.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/dz/3d8j_wx508jgkxqzjrfwhbt40000gp/T/python-build.20230125165700.93087
Results logged to /var/folders/dz/3d8j_wx508jgkxqzjrfwhbt40000gp/T/python-build.20230125165700.93087.log
Last 10 log lines:
DYLD_LIBRARY_PATH=/var/folders/dz/3d8j_wx508jgkxqzjrfwhbt40000gp/T/python-build.20230125165700.93087/Python-3.9.12 ./python.exe -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
echo "generate-posix-vars failed" ; \
rm -f ./pybuilddir.txt ; \
exit 1 ; \
fi
dyld[4402]: symbol not found in flat namespace (_libintl_bindtextdomain)
/bin/sh: line 1: 4402 Abort trap: 6 DYLD_LIBRARY_PATH=/var/folders/dz/3d8j_wx508jgkxqzjrfwhbt40000gp/T/python-build.20230125165700.93087/Python-3.9.12 ./python.exe -E -S -m sysconfig --generate-posix-vars
generate-posix-vars failed
make: *** [pybuilddir.txt] Error 1
I'm on an M1. Not sure if that has anything to do with it.

I am getting the same error trying to install 3.9.16 on an M1 mac. I tried reinstalling xcode-select and everything else I could find online. nothing worked. I found this issue that suggests building with rosetta, but that did not work either.
Edit: I fixed my installation but I am really skeptical it will be useful to anyone else. I had just installed the FreeSurfer toolkit for neuroimaging and it turns out that it adds many directories to PATH. Removing the FreeSurfer specific part of PATH for the installation resolved the problem.
For example, executing the following in your terminal:
$ echo PATH
/Applications/freesurfer/bin:/other/freesurfer/or/fsl/dirs:my/path
$ PATH=my/path:without/freesurfer/tings pyenv install 3.9.16
Of course, one would need to replace the PATH before the pyenv command with something relevant to their machine.
The specifics of this solution are unlikely to be useful to many people but maybe other programs also mess with PATH significantly and could cause a similar error.

Related

Unexpected output of 'arch' on OSX (using Mac M1 installing elastic beans)

when trying to install elastic beans on MacBook Air M1, using the following:
% ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer
as guidelines shown here:
https://github.com/aws/aws-elastic-beanstalk-cli-setup
I get the following error:
5. Installing Python 3.7.2. This step may take a few minutes
************************************************************
python-build: use openssl from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.2.tar.xz...
-> https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
Installing Python-3.7.2...
python-build: use readline from homebrew
BUILD FAILED (OS X 11.1 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/2v/7tdwpjsd3jzdw75jmp2n5trh0000gn/T/python-build.20201225141032.70517
Results logged to /var/folders/2v/7tdwpjsd3jzdw75jmp2n5trh0000gn/T/python-build.20201225141032.70517.log
Last 10 log lines:
checking size of _Bool... 1
checking size of off_t... 8
checking whether to enable large file support... no
checking size of time_t... 8
checking for pthread_t... yes
checking size of pthread_t... 8
checking size of pthread_key_t... 8
checking whether pthread_key_t is compatible with int... no
configure: error: Unexpected output of 'arch' on OSX
make: *** No targets specified and no makefile found. Stop.
Exiting due to failure
Thank you for helping!!!
None of the above worked for me. I installed both brew for Apple Silicon and Intel:
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
And then installed pyenv from:
/usr/local/Homebrew/bin/brew install pyenv
/usr/local/Homebrew/bin/brew link pyenv
arch -x86_64 pyenv install 3.8.9
And that worked
Edit
As Cheesus points in the comments, seem the only thing to do is the last line:
arch -x86_64 pyenv install 3.8.9
I also just switched to an M1, and I also got the same error. (coming from pyenv install 3.8.9.)
Installing 3.8.10 worked for me. They mention the M1 specifically on the 3.8.10 releases page, so maybe something had to be sorted out:
Python 3.8.10 ships two installers: the default 64-bit-only that works on macOS 10.9 (Mavericks) and later systems, and an experimental "universal2" installer for macOS 11 (Big Sur) and later
(This is if you need 3.8x for whatever reason. They're on 3.9.x right now.)
The arch command can be used to run specific commands via Rosetta:
arch -x86_64 ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer
Run the terminal using Rosetta - a translation process that allows users to run apps that contain x86_64 instructions on Apple silicon.
To do so -
command+space, type: Utilities => will get you to the utilities folder
duplicate the terminal app - call it terminal_x86
terminal_x86 => get info, mark open using Rosetta
For those who are managing python version using pyenv.
This worked for me on mac M1.
CC=/opt/homebrew/bin/gcc-11 arch -x86_64 pyenv install 3.8.6
If you are using pyenv to manage python in your machine. Did you already try this:
pyenv install --patch 3.8.6 <<(curl -sSL https://raw.githubusercontent.com/Homebrew/formula-patches/113aa84/python/3.8.3.patch\?full_index\=1)
like was related here:
https://github.com/pyenv/pyenv/issues/1768#issuecomment-753756051
If you having the same problem after running the code above try:
softwareupdate --all --install --force
sudo rm -rf /Library/Developer/CommandLineTools
sudo xcode-select --install
like was related here:
https://github.com/pyenv/pyenv/issues/2201#issuecomment-1001597344
Them:
https://raw.githubusercontent.com/Homebrew/formula-patches/113aa84/python/3.8.3.patch\?full_index\=1)
This is how I solved it on my Macbook air M1.
M1 on Mac seems to be "too updated". So you would need to update to a higher version for both python & pip using: pyenv install 3.8.10
easiest solution is just use brew to install ebcli.
brew install awsebcli.
it will handle all the weird mac related variations for you
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install-osx.html
If you're here not because of elastic beans, but because of pyenv and you're also getting the error Unexpected output of 'arch' on OSX then try installing a later/different version of python. I experienced this when installing 3.7.0, but installing 3.7.12 worked for me.

Downgrade to python 3.6.5 with brew: Error /bin/sh: sphinx-build: command not found make: *** [build] Error 127

Please, I'm downgrading to Python 3.6.5 using brew, but I got this error:
Command:
brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Error:
mkdir -p build
Using existing Misc/NEWS file
PATH=./venv/bin:$PATH sphinx-build -b html -d build/doctrees -D latex_elements.papersize= . build/html
/bin/sh: sphinx-build: command not found
make: *** [build] Error 127
Do not report this issue to Homebrew/brew or Homebrew/core!
These open issues may also help:
Python 3.7.2 install fails https://github.com/Homebrew/homebrew-core/issues/36753
pagmo: build with python binding https://github.com/Homebrew/homebrew-core/pull/36445
python#2: fix zlib with CLT on 10.14 https://github.com/Homebrew/homebrew-core/pull/34562
Can someone help me?
PS: Xcode is already installed, I run brew unlink python (to unlink 3.7), sphinx-build is on /usr/local/bin/sphinx-build.
The brew formula for 3.6.5 has some issues. Here is a open issue on github about this error.
I have decided to change to pyenv with pyenv-virtualenv in order to avoid using brew switch python 3.xx all time.
As I need to use many different installations of Python on the same machine, 2.7 and 3.4 for example and many virtual environments, just brew swicth and virtualenv is not working well.
See python.rb formula for 3.6.8
Step-by-step instructions, with transcript, in my comment in fork:
I had to leave in, that is not comment out the
depends_on sphinx-doc" => :build
to build from source as detailed in my fork comment:
gisthub dukechem fork of python.rb formula for 3.6.8

Scapy installation fails due to invalid token

I have recently taken up learning networks, and I want to install scapy.
I have downloaded the latest version (2.2.0), and have two versions of python on my computer- 2.6.1 and 3.3.2. My OS is windows 7 64 bit.
After extracting scapy and navigating to the correct folder in the terminal, I was instructed to run "python setup.py install". I get the following error-
File "setup.py", line 35
os.chmod(fname,0755)
................................^
......................invalid
token
(dots for alignment)
How do I solve this problem?
Update: scapy-python3 is deprecated (2018) and will no longer be updated. scapy>=2.4.0 has merged python 3 compatibility.
The most up-to-date installation method is now
pip3 install scapy>=2.4.0
You may check the installation page in the documentation for other installation methods
Original answer:
Perhaps you are trying to install the package scapy for Python 2, but you need the one for Python 3.
pip install scapy
gave this error:
os.chmod(fname,0755)
^
SyntaxError: invalid token
while
pip3 install scapy-python3
did a proper install.
This error means the octal number is not recognized by Python 3, see PEP 3127:
octal literals must now be specified with a leading "0o" or "0O" instead of "0";
The following works for me on Python 3.5
pip3.5 install scapy-python3
Change os.chmod(fname,0755) to os.chmod(fname,0o755) and re-run
If pip installation is causing problem. You can download using wget and try to install.
$ cd /tmp
$ wget --trust-server-names scapy.net
$ unzip scapy-x.x.x.zip
$ cd scapy
$ sudo python setup.py install
Check here for all ways of installing scapy.
Scapy mainly used on uinx-liked OS, and can't install by pip. But they offered msi installer for windows:
http://www.secdev.org/projects/scapy/doc/installation.html
The error also occurs on Linux, but virtualenv saves me.Virtualenv is a really good solution of using different version python or librarys on one OS.
virtualenv -p $python_bin_path $virtualenv_directory_name
Creating a virtual env with python2 and python3:
virtualenv -p `which python` project_with_python2
virtualenv -p `which python3` project_with_python3
Then active the env, and install the requirements.
cd project_with_python2
source bin/activate
pip install scapy
pip install -r requirements.txt
And using deactivate to exit env.

Setup PyYaml with pyenv on Mac OS X; file not found: python.exe

I'm having trouble installing python packets using pip in a virtualenv. After some investigations, it turns out there seems to be a problem with PyYaml. I downloaded the last version and tried to build it. When using the "system" python, there is no problem. However, when I try to run the same command (python setup.py install) after activating my virtualenv, I get the following error:
gcc -bundle -bundle_loader python.exe -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib - L/Users/a/.pyenv/versions/2.7.7/lib build/temp.macosx-10.10-x86_64-2.7/ext/_yaml.o -lyaml -o build/lib.macosx-10.10-x86_64-2.7/_yaml.so
ld: file not found: python.exe
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
I have no idea where it comes from... Any clue?
I ran into the same issue using pyenv. The dirty way I got it to install was using
CC=/path/to/virtualenv_dir/bin/python2.7 /path/to/virtualenv_dir/bin/pip install pyyaml
If you're using pyenv you can also use
CC=$(which python) pip install pyyaml
As discussed in pyenv#273, the problem happens after installing Python <2.7.8 on macOS.
You can fix it yourself:
$ export p=/Users/andrei/.pyenv/versions/2.7.6
$ sed -i -e "s#python.exe#${p}/bin/python2.7#g" "$p/lib/python2.7/_sysconfigdata.py"
The example is for 2.7.6, replace the version if you need 2.7.7 etc.
If you don't use pyenv, change the path to where Python is stored.

How to make Mac OS use the python installed by Homebrew

I have searched online for a while for this question, and what I have done so far is
installed python32 in homebrew
changed my .bash_profile and added the following line to it:
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
but when I close the terminal and start again, I type 'which python', it still prints:
/usr/bin/python
and type 'python --version' still got:
Python 2.7.2
I also tried the following instruction:
brew link --overwrite python
or try to remove python installed by homebrew by running this instruction:
brew remove python
but both of the above two instructions lead to this error:
Error: No such keg: /usr/local/Cellar/python
can anybody help, thanks
brew install python or brew info python output mentions:
Unversioned symlinks python, python-config, pip etc. pointing to
python3, python3-config, pip3 etc., respectively, have been installed into
/opt/homebrew/opt/python#3.9/libexec/bin
So running
% echo 'export PATH=/opt/homebrew/opt/python#3.9/libexec/bin:$PATH' >> ~/.zprofile
% source ~/.zprofile
# For bash use ~/.bash_profile.
gets you those symlinks created by Homebrew - python=python3, pip=pip3 etc
% python --version
Python 3.9.10
% pip --version
pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)
If you want to install Python 3 using Homebrew:
$ brew install python3
==> Downloading http://python.org/ftp/python/3.3.0/Python-3.3.0.tar.bz2
Already downloaded: /Library/Caches/Homebrew/python3-3.3.0.tar.bz2
==> ./configure --prefix=/usr/local/Cellar/python3/3.3.0 --enable-ipv6 --datarootdir=/usr/local/Cell
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python3/3.3.0/share/python3
==> Downloading https://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
Already downloaded: /Library/Caches/Homebrew/distribute-0.6.35.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz
Already downloaded: /Library/Caches/Homebrew/pip-1.3.1.tar.gz
==> /usr/local/Cellar/python3/3.3.0/bin/python3.3 -s setup.py install --force --verbose --install-li
==> Caveats
Homebrew's Python3 framework
/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework
Distribute and Pip have been installed. To update them
pip3 install --upgrade distribute
pip3 install --upgrade pip
To symlink "Idle 3" and the "Python Launcher 3" to ~/Applications
`brew linkapps`
You can install Python packages with
`pip3 install <your_favorite_package>`
They will install into the site-package directory
/usr/local/lib/python3.3/site-packages
Executable python scripts will be put in:
/usr/local/share/python3
so you may want to put "/usr/local/share/python3" in your PATH, too.
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
Once installed update your system PATH variable, add the next line to ~/.bash_profile
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
And then:
$ source ~/.bash_profile
Now launch Python:
$ python3
Python 3.3.0 (default, Mar 26 2013, 10:01:40)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
You can check python3 path:
$ which python3
/usr/local/bin/python3
You may try adding this line to your .bash_profile
alias python='python3'
I came through the same issue and did some research. I found that someone has created a bug for the same issue under the azure/cli repository. You can find that issue here. I am providing the same solution here which was very easy and fixed my issue:
Most probably the Brew is broken and needs some patching or fixing. So run brew doctor command which will give you a summary about what is happening.
Below is what I got:
mymac:bin sidmishra$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: The following directories do not exist:
/usr/local/sbin
You should create these directories and change their ownership to your account.
sudo mkdir -p /usr/local/sbin
sudo chown -R $(whoami) /usr/local/sbin
Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected dylibs:
/usr/local/lib/LibSideSyncOSX9.dylib
/usr/local/lib/ss_conn_lib.dylib
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
python
The awesome stuff about the command brew doctor is that it not only tells you issues but also suggests you the solution steps in most of the cases.
So, I ran all the commands suggested by the brew and to link I ran the following command:
brew link python
Above command threw me an error:
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... Error: Permission denied # dir_s_mkdir - /usr/local/Frameworks/Python.framework
It seems that /urs/local/Frameworks doesn't have enough rights for my current user. So, I ran the following command and gave enough rights to my current user:
sudo chown -R $(whoami) /usr/local/Frameworks/
After running above command I ran linking command again, and it worked!!!
mymac$ brew link python
Linking /usr/local/Cellar/python/3.7.1... 1 symlinks created
Now run following command to get the current selected python version:
python --version
Above command should give you 3.7.1 (as of 21st Dec 2018) or new version for the python. There might be a chance that your Mac would have python2 set by default. If the version is not python3 then you have to a couple of steps to use the latest python3 over python2 version. Here are the steps:
Using Shell:
Open ~/.bash_loginor ~/.bash_profileor ~/.cshrcor ~/.profileor ~/.tcshrcor ~/.zprofile, whatever shell you are using for commands, in edit mode. You may have to use sudo to edit them.
Add following steps to it:
PATH="/Library/Frameworks/Python.framework/Versions/3.2/bin:${PATH}"
export PATH
Also, add following for backup:
alias python=python3
OR
Using homebrew:
Run following commands to unlink python2 and link python3:
mymac$ brew unlink python#2
mymac$ brew link python#3
Above will unlink python2 and link python3.
Hope some of you will get helped from this answer.
Good Day!!!
From $ brew info python:
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Then confirm your python executable corresponds to the correct installation:
$ which python or
$ python --version
Installing with Homebrew is recommended on macOS. That being said, Python 2.7 comes with Mac OS; however, it is deprecated and will be removed soon. As such, you should be using Python3 and newer.
Install Homebrew.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Run brew install python
Once Python is installed, Homebrew will say that the installation is complete, but that you already have Python 2.7 installed. This is nice, but we want to set it to actually see python3 as an option
Use brew link
Confirm by running which python3, the path should be /usr/local/bin/python3

Categories