Using Python3 on macOS as default but pip still get using python 2.7

2024/10/9 2:28:17

I'm using macOS Big Sur 11.0.1.

I'm setting up a virtual env

$python3 -m venv $my_workdir)/.virtualenv

but getting this error at building wheel package:

building '_openssl' extensioncreating build/temp.macosx-10.14.6-x86_64-3.8/buildcreating build/temp.macosx-10.14.6-x86_64-3.8/build/temp.macosx-10.14.6-x86_64-3.8clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -I/usr/local/opt/gettext/include -I/Users/engontang/devspace/energisme/terraform/tfwrapper-infra-pda/.wrapper/.virtualenv/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c build/temp.macosx-10.14.6-x86_64-3.8/_openssl.c -o build/temp.macosx-10.14.6-x86_64-3.8/build/temp.macosx-10.14.6-x86_64-3.8/_openssl.o -Wconversion -Wno-error=sign-conversionbuild/temp.macosx-10.14.6-x86_64-3.8/_openssl.c:575:10: fatal error: 'openssl/opensslv.h' file not found#include <openssl/opensslv.h>^~~~~~~~~~~~~~~~~~~~1 error generated.error: command 'clang' failed with exit status 1 ----------------------------------------ERROR: Failed building wheel for cryptographyBuilding wheel for pynacl (PEP 517) ... /

As wheel is prebuilt with pip I thought it could be a pip upgrade issue, so I checked my pip version :

$pip --version                                                                                                                                                                                                      
pip 20.2b1 from /Library/Python/2.7/site-packages/pip-20.2b1-py2.7.egg/pip (python 2.7)

I don't understand why python 2.7 is still mentionned above while my default python version is :

$python -V                                                                                                                                                                                                          
Python 3.8.2

Trying however to upgragde pip results in this :

$pip install --upgrade pip --user                                                                                                                                                                                   
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting pipUsing cached pip-20.2.4-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pipWARNING: The scripts pip, pip2 and pip2.7 are installed in '/Users/engontang/Library/Python/2.7/bin' which is not on PATH.Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.2.4

Using pip3 command gives the same result. You can see the DEPRECATION: Python 2.7 message above, and also pip still showing up the same version rather than 20.2.4:

$pip --version                                                                                                                                                                                                       
pip 20.2b1 from /Library/Python/2.7/site-packages/pip-20.2b1-py2.7.egg/pip (python 2.7)

And my virtualenv setup still lead to the same above error.

Can one here say why pip is still looking at python 2.7 site packages, and what could be the problemm with wheel package build?

Answer

For devices using Apple Silicon you may try this (as default homebrew bin directory differs)

  export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

You can view the command by yourself entering

brew info openssl
https://en.xdnf.cn/q/70073.html

Related Q&A

Python Matplotlib Box Plot Two Data Sets Side by Side

I would like to make a boxplot using two data sets. Each set is a list of floats. A and B are examples of the two data setsA = [] B = []for i in xrange(10):l = [random.random() for i in xrange(100)]m =…

perform() and reset_actions() in ActionChains not working selenium python

This is the code that habe no error: perform() and reset_actions() but these two functions have to work combinedly import os import time from selenium import webdriver from selenium.webdriver.common.ac…

nosetests not recognized on Windows after being installed and added to PATH

Im on exercise 46 of Learn Python the Hard Way, and Im meant to install nose and run nosetests. Ive installed nose already using pip, but when I run nosetests in the directory above the tests folder, I…

Using a context manager with mysql connector python

Im moving my code across from an sqlite database to mysql and Im having a problem with the context manager, getting the following attribute error.Ive tried combinations of mydb.cursor() as cursor, mydb…

Value of Py_None

It is clear to me that None is used to signify the lack of a value. But since everything must have an underlying value during implementation, Im looking to see what value has been used in order to sign…

Getting the href of a tag which is in li

How to get the href of the all the tag that is under the class "Subforum" in the given code?<li class="subforum"> <a href="Link1">Link1 Text</a> </l…

Put value at centre of bins for histogram

I have the following code to plot a histogram. The values in time_new are the hours when something occurred.time_new=[9, 23, 19, 9, 1, 2, 19, 5, 4, 20, 23, 10, 20, 5, 21, 17, 4, 13, 8, 13, 6, 19, 9, 1…

plot in Pandas immediately closes

I have a problem of plotting the data. I run the following python code:import pandas as pd df = pd.read_csv("table.csv")values = df["blah"] values.plot() print 1df[blahblah].plot() …

Django template: Embed css from file

Im working on an email template, therefor I would like to embed a css file<head><style>{{ embed css/TEST.css content here }}</style> </head>instead of linking it<head><…

handling async streaming request in grpc python

I am trying to understand how to handle a grpc api with bidirectional streaming (using the Python API).Say I have the following simple server definition:syntax = "proto3"; package simple;serv…