pyenv and installing certain Python packages - python

I'm trying to install an older version of Python on my Mac. I'm currently running 2.7.9, but our production environment is running 2.7.6. (There is a compatibility issue with gevent and 2.7.9.)
I found pyenv which allows me to install various versions. I've installed pyenv with brew and installed 2.7.6. I then created a virtualenv with 2.7.6 with the following command:
mkvirtualenv my_env --python=/Users/dustin/.pyenv/versions/2.7.6/bin/python
It seems to work fine and I'm running Python 2.7.6. The problem I am running into is that I can't install certain packages with pip such as Cython or M2crypto. I get C compile errors.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
If I create a virtualenv without specifying the Python version, these packages install fine. How do I fix this?

It could be due to trying to run an older version of Python 2.7.x (like 2.7.6) on newer releases of OS X. If you are on OS X 10.10, that's very likely the problem. See http://bugs.python.org/issue21811. You may need to add at least the patch for _osx_support.py. If not, try running pip with -v and update your question with the results.
Update: With the additional information you supplied, it is clear that you are running into the OS X 10.10 support issues that were fixed in the changes for Issue21811 released in 2.7.8. In particular, the configure changes are needed to correctly parse the two-digit minor version number (10); otherwise, the code in configure mistakenly thinks you are are running on a very old version of OS X and generates obsolete link directives. You should backport https://hg.python.org/cpython/rev/2672e30d9095 and https://hg.python.org/cpython/rev/a7ab09e00dbc.

Related

failed to install python versions using pyenv on macos

I am trying to install python 3.8.5 using pyenv on my new MacBook Pro.
I was able to install pyenv successfully and confirmed it was working fine.
It is quite weird as I was able to install python 3.9.2 successfully using pyenv on my MacOS.
The problem arises when I tried to install another python version such as 3.8.5.
I get the error messages as below.
~ ยป pyenv install 3.8.5
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.8.5.tar.xz...
-> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
Installing Python-3.8.5...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
BUILD FAILED (OS X 11.2.2 using python-build 20180424)
Inspect or clean up the working tree at /var/folders/gm/wv5zbtxx6gl2cbg9yszmxnzc0000gn/T/python-build.20210403160603.37920
Results logged to /var/folders/gm/wv5zbtxx6gl2cbg9yszmxnzc0000gn/T/python-build.20210403160603.37920.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.
I tried to follow some ways to resolve the issue as described in
https://github.com/pyenv/pyenv/wiki/Common-build-problems (common build problem)
However, I get the same outcome each time I try to install python versions using pyenv.
I am new to MacOS, I would like to get some advice on this. Could anyone help on this?
Thank you very much!
the error you are facing may be caused by an older version of the xcode command line tool.
Please try typing and running the following command.It may change something.
xcode-select --install
LDFLAGS="-L$(xcrun --show-sdk-path)/usr/lib" pyenv install 3.8.5
I hope it works for you.
I installed first python 3.10.3 and the project which I was trying to execute requires python 2 for that reason I tried to install using pyenv install 2.7.9 but I got ld: symbol(s) not found for architecture i386. I fixed it installing.
brew install openssl readline sqlite3 xz zlib
as it is recommended in the documentation

unable to install pymorph

I'm trying to install 'pymorph' on mac os x with 'PIP':
sudo pip install pymorph
I'm getting the following error:
NameError: name 'execfile' is not defined
Command "python setup.py egg_info" failed with error code 1 in
/private/tmp/pip-build-9hjd5tfm/pymorph/
I have read that using a python version different from 2.7 could lead to this kind of problem. Yet, I'm using the 2.7 version:
python --version
Python 2.7.13
Any ideas to solve this issue ?
Thank you in advance
It's possible to have a pip command on your PATH that comes from a different Python installation than the python command. (Each entry script to a Python-based tool is bound to the Python installation that was used to install the package that provided it. This means that the pip command does not search PATH for a python installation.) If this pip comes up later on PATH than python, it would lead to behaviour that you describe.
This can happen, say, if you first install a Python 2.7 without pip, and then a Python 3.x with pip, if the installers prepend to PATH.
You can verify which version of Python pip is using and where it's installed by running pip -V.
The robust solution to this should be using a virtual environment that lets you tie the base python installation and libraries specific to your application alone with your project, as well as avoid cluttering your global site-packages, and prevent inadvertent compatibility issues from different versions of the same package being needed by different projects.
It seems that the current (as of late 2017) recommended virtual environment solution is Pipenv. A decent-looking introduction to virtual environments using Pipenv, by the author of Pipenv, can be found here.

Python(x,y): MinGW installation - MWE

Background
I reinstalled Python(x,y) on my Windows 7 machine. When I finished the installation I wanted to upgrade all packages using pip. But the mingw compiler gives some weird error messages.
My last question could hopefully get resolved by this issue: Python: Install sip
Therefore I checked out an example online that builds C code for Python using mingw. But it failed - that might be an indication that mingw is not working as intended. I have some details if this helps anything:
mingw32-make --version 3.82.90
gcc --version 4.8.1
python --version 2.7.10
I configured Python (C:\Python27\Lib\distutils\distutils.cfg) according to the qutip installation guide and https://docs.python.org/2/install/#location-and-names-of-config-files.
Issue
I want to test my mingw installation since I cannot upgrade the Python packages with pip. Please give me some tested code to check if my installation is working properly together with Python.

mac following brew install python warning thrown unstable state

Pundits warn against installing python in a mac usr/bin/Frameworks area.
Python self-installers write to Framework by default.
pundits advise using brew install of python to avoid the above.
Brew install python however, results in unstable state
Idle reports tclsh mismatch.
Pundits advise active state installer of correct tclsh. These are high-level python cognoscenti, and real pundits, lilies amidst the thorns.
Active-state installs to Frameworks (can you imagine?).
The said installer allows no other installation directory.
Brew installed python fails to see the active-state tclsh.
However, if one of you admonitory pundits could help me with a logical, non-idiomatic description of a process that will associate the appropriate "tclsh" in usr/bin with python3 in usr/local/bin, I would be ecstatic.
Homebrew's Python build will only attempt to recognize brewed or system Tcl/Tk. To build against Homebrew's Tcl/Tk (and install it first if necessary), install Python with brew install python3 --with-tcl-tk.

How do you solve this VirtualEnv Running on Jython Error?

I am able to successfully run virtualenv on python, not but on jython (version 2.5.2). What could be the problem and how do I fix this?
Below is the error:
Susans-MacBook-Pro:Intro_Jython susantan$ virtualenv -p jython susan_env_jy
Running virtualenv with interpreter /Users/susantan/jython2.5.2/bin/jython
ERROR: None
ERROR: this script requires Python 2.6 or greater.
Susans-MacBook-Pro:Intro_Jython susantan$ virtualenv -p python susan_env_jy
Running virtualenv with interpreter /usr/bin/python
New python executable in susan_env_jy/bin/python
Installing setuptools, pip...done.
From the Jython website:
The most current stable release of Jython is 2.5.3. For production purposes, please use this version.
From your error message:
ERROR: this script requires Python 2.6 or greater.
This is probably the cause of the problem. Jython has a 2.7beta1 which you could try.
Edit: from the virtualenv website, it looks like they dropped support for Python 2.5 in v1.10:
1.10 (2013-07-23) ~~~~~~~~~~~~~~~~~
BACKWARDS INCOMPATIBLE Dropped support for Python 2.5. The minimum
You will have to install an earlier version of virtualenv to support Jython 2.5.x
Here is a link to the previous version (1.9.1) https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.9.1.tar.gz - You should be able to install this by extracting the package and running jython setup.py install from within the folder.

Categories

Resources