I'm trying to install Python3 on a Mac OS X Yosemite, and did that by running the following command:
$ brew install python3
When I tried that, I got the following error:
clang: error: unable to find utility "clang", not a developer tool or in PATH
otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
How can I fix this issue?
Thanks.
Try brew update and then brew doctor first. The doctor diagnoses common issues.
Seems something's wrong with your Xcode/Command Line Tools. This answer might be helpful.
I would highly recommend using the anaconda distribution, in particular miniconda.
For OSX Yosemite, this is a link to the Python 3.4 64-bit installer.
After downloading the application, open a terminal window, navigate to where you downloaded the app (e.g. cd ~/Downloads) and type:
bash Miniconda-latest-MacOSX-x86_64.sh
Now close and re-open your terminal window for the changes to take effect.
To test your installation, enter the command conda list from the terminal. If installed correctly, you will see a list of packages that were installed.
From here, you should be able to follow the on-screen instructions. If you get lost, you can refer to their installation guide.
After installing conda, you need to create an environment. To install an new environment named py3 with Python 3:
conda create --name py3 python=3
To activate this environment:
source activate py3
Here, I normally install iPython, iPython notebook and pyqt:
conda install ipython, ipython-notebook, pyqt
Now, to activate an ipython shell from within your environment:
ipython qtconsole
Although this reply does not attempt fix the homebrew issue, it answers the question of how to install Python3 on Mac OS X Yosemite.
Open Terminal and
[Try]: brew update
[or Homebrew Install]: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(code source found at https://brew.sh/)
Make sure processes finish, and then [Re-Try]: brew install python3
For me, I ran brew doctor which said
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:
pandoc
heroku
numpy
unbound
python#3.8
So I ran brew link python#3.8
And immediately after, python3 suddenly works!
Related
gdal is correctly installed on my global system's python 3.5 packages.
But now I'm trying to pip install gdal on my python 3.6 virtual environment, but I receive multiple errors.
After activating the virtual environment, I've tried the following:
pip install pygdal or pip3 install pygdal
Error received: ERROR: Failed building wheel for pygdal
Tried following this guide, but the commands stated there are outdated
I've also tried this solution and this which failed
Installed older gdal versions but also didn't work.
Tried pip3 install GDAL==$(gdal-config --version) and I get the same error
I use
Ubuntu 16.04 and pip 21.0.1. Venv was created using virtualenv --python=/usr/bin/python3.6 my_venv
I've finally fixed the problem, and these are the steps I followed:
I uninstalled wheel from my venv
Then I pip installed gdal on the venv to check what error would appear
A wall of error text appeared, in which somewhere I noticed the 'x86_64-linux-gnu-gcc' failed with exit status 1
I typed sudo apt-get install python3.6-dev to install missing packages, as the solution suggests here
Then I ran pip install GDAL=<version that appears on ogrinfo --version> and it worked
EDIT: This answer pertains more to Windows than Ubuntu, but may have something useful.
Try downloading a wheel from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Note the "cp##" in the middle - that should match your Python version. If you are running Python 3.6 then you should see "cp36" in the file name (a "cp37" in the name means the wheel will fail). Also pay attention to the amd64 and win32 to be sure you have the correct version to match your Python virtual environment.
I'm on Windows instead of Ubuntu, but this was my process:
Open command prompt with cmd
Copy the path to activate.bat in the virtual environment from Windows Explorer (hold shift down, right-click on file, choose
"copy as path")
Paste path into control panel and hit enter. You should see an indicator that you are in virtual environment.
Copy the path to the wheel you downloaded to the clipboard using the same shift key trick.
Type 'pip install ' then paste the wheel path from your clipboard (or type it all out manually)
As an aside, I ended up with gdal installed within the osgeo module. I tried several things before I got here, but I'm pretty sure that happened with my installation from the wheel. In Python, I now use
from osgeo import gdal
I hope something here helps you. I've run into this a few times and it never seems like I quite remember how I got it done the next time I run into it. If I remembered it right this time, I can refer back here.
FWIW - I am using PyCharm and installing gdal through the Project Interpreter doesn't work. Also, it may take some jostling in PyCharm for the skeletons to update after you install through command prompt.
Now. When I run it. The error comes
ImportError:
dlopen(/Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so,
2): no suitable image found. Did find:
/Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so:
mach-o, but wrong architecture
/Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so:
mach-o, but wrong architecture
After hours of trial and error, I was finally able to solve this. My successful configuration is:
Open terminal with Rosetta 2 (https://dev.to/courier/tips-and-tricks-to-setup-your-apple-m1-for-development-547g)
Use non-homebrew python (mine was in /usr/bin/python3) to create virtual environment
/usr/bin/python3 -m venv env
source env/bin/activate
Upgrade pip
pip install --upgrade pip
Install PyQt5
pip install PyQt5
I needed PyQt5 as a dependency for a Python library and this worked for me. See original post here.
brew install pyqt5
echo 'export PATH="/opt/homebrew/opt/qt#5/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/pyqt#5/5.15.4_1/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
What I ended up doing specifically for pyqt5 was:
brew install pyqt#5
I think for versions 4 and 6 this may work as well. When I went simply brew install pyqt that didn't work unfortunately.
note this is M1 Macbook only
One other thing to try as things settle down with M1s is to try pip3 install pyqt5 in a terminal launched in Rosetta mode (left click -> Get Info -> Open in Rosetta)
Edit (Nov 2022)
It seems that if you don't specifically need pyqt5, pyqt6 is now easily installable via pip on M1/M2 Macs.
python -m pip install pyqt6
I was hoping to install pyqt5 on my M1 mac without Rosetta. I was using it as a dependency of another project that I wanted to install in a venv which requires pyqt5 and was not installable via pipx (urh).
Unfortunately, there currently are no compatible wheels (curl --silent "https://pypi.org/pypi/PyQt5/json" | grep -i arm64), and attempting to install on 3.10 fails with AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'
Thankfully, the homebrew installation of pyqt5 is compiled for arm64 and works well.
My steps were:
$ # Install pyqt5 via homebrew
$ brew install pyqt#5
$ # Note that it's installed in python3.9, not 3.10
$ brew cat pyqt#5 | grep 'depends_on.*python'
depends_on "python#3.9"
$ # Make a python3.9 virtualenv with access to the system's site-packages
$ /opt/homebrew/bin/python3.9 -m venv --system-site-packages .venv
$ source .venv/bin/activate
At this point I was able to install urh into the virtualenv, using the arm64-compiled pyqt5 from hombrew, without neededing Rosetta (and without needing to further "pollute" my system site-packages), and it runs as expected (since the question was about running).
Try installing the pyqt under the ARM architecture as below
arch -arm64 brew install pyqt
In my case it's work: arch -x86_64 brew install pyqt
And all required pyqt start from arch -x86_64 or start from rosetta (through emulator).
You can use it from homebrew, this is the only way I found it working on Mac M1.
First:
brew install pyqt#5
Then:
brew --cellar
brew link --overwrite python
Then you must create/add an alias for python and put it in your .zprofile (Located in Users/username folder, if you press Shift+command+.
This must point to your homebrew python installation location.
alias python ='opt/homebrew/bin/python3'
That way it will link python with your homebrew python and you can run python test.py from terminal (Where your python files are located).
No matter how I tried with pip install, it just shown error and did not work.
I wanted to run PyQt5 under virtual environment with Python3.6.
The following procedures worked for me.
My settings are MBA M1 2020, macOS 11.3.1, and
pyenv versions
> system
> * 3.6.15
pip -V
> pip 21.3.1 from /Users/username/.pyenv/versions/3.6.15/lib/python3.6/site-packages/pip (python 3.6)
Then simply run:
pip install pyqt5-sip
pip install pyqt5
on the terminal (default one, not the one with Rosetta 2).
I had to install PyQt5==5.15.6on my MacM1 into an existing virtual environment.
It did not work using all the methods described here.
So, what I did is :
Open the terminal in rosetta mode
Navigate to my project and activate the virtual environment source venv/bin/activate
Install the package : pip install PyQt5==5.15.6
Open a regular terminal into my project and make sure everything was installed as per the requirements.txt : pip install -r requirements.txt
Everything is running smoothly, now.
If anyone is still having the same problem with installation of PyQT5, I would suggest you to rather lock your focus on PySide6. It is 99% similar to PyQT5 and works well with MacBook m1.
I've been digging the Internet for hours hoping to find the solution but it appears that PyQT5 and PyQT5-tools modules are somewhat broken on MacBook M1 when it comes to downloading them.
I was struggling with installing PyQt5 on M1 mac with MacOS 12.6 (Monterey) inside a virtual environment (using python 3.9). The final solution that worked for me was to use conda for creating and activating the virtual environment.
conda create --name venv python=3.9 conda activate venv
And then simply using conda to install PyQt5 as part of the pyqt package.
conda install pyqt
PyQt6 is out now and supports apple silicon:
https://stackoverflow.com/a/75224682/19486832
No conda support, but pip install is working fine:
python -m pip install PyQt6
I have just tried to install Anaconda using Home-brew using the terminal, and receive the following message:
L-MBP:agda-stdlib le$ brew install conda
Updating Homebrew...
Error: No available formula with the name "conda"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
L-MBP:agda-stdlib le$ brew install anaconda
Error: No available formula with the name "anaconda"
Found a cask named "anaconda" instead. Try
brew cask install anaconda``
L-MBP:agda-stdlib le$ brew cask install anaconda
==> Caveats
Cask anaconda installs files under /usr/local. The presence of such
files can cause warnings when running `brew doctor`, which is considered
to be a bug in Homebrew Cask.
...
installation finished.
==> Changing ownership of paths required by anaconda; your password may be necessary
🍺 anaconda was successfully installed!
L-MBP:agda-stdlib le$ conda create --name snakes python=3.7.2
-bash: conda: command not found
L-MBP:agda-stdlib le$ conda -bash: conda: command not found
When I try to open anaconda and when I try to make a Python environment, I receive the message ''command not found''.
What is the problem?
Install anaconda via Homebrew
Install anaconda via brew cask by executing
➜ brew cask install anaconda (or)
➜ brew install --cask anaconda [Newer versions of Homebrew]
.
.
.
PREFIX=/usr/local/anaconda3
.
.
.
🍺 anaconda was successfully installed!
Let’s run jupyter notebook
Try to executing jupyter notebook in your terminal.
It’s not works … why? Because our shell doesn’t know where is the anaconda folder so is, let’s add that folder to our shell path.
Setup the environment path.
Insert a line below on top of your ~/.zshrc file because when you trying to execute python on terminal it’ll search on folder /usr/local/anaconda3/bin first before search on default operating system path which means you can execute jupyter notebook and python .
export PATH="/usr/local/anaconda3/bin:$PATH"
Restart terminal or use source ~/.zshrc to reload your shell environment and execute jupyter notebook an output will be like this
Reference: Install anaconda on macOS with Homebrew
To install Anaconda using Homebrew:
Go to your terminal and type brew cask install anaconda, then hit return.
Make sure that anaconda is in your PATH. You'll need to open your terminal's configuration file (usually this is ~/.zshrc on a mac) and find the line that starts PATH=. Add a line nearby that says: export PATH="/usr/local/anaconda3/bin:$PATH". This is where Homebrew installs Anaconda.
Quit and restart your terminal. This is the easiest way to make sure that the new configuration will be loaded.
Test whether it's working with which conda.
You should now be able to use the conda command.
EDIT: As similar posts in this topic have pointed out, the way conda activate works has changed from version to version. If the above isn't giving you good enough results, try the following method to enable the conda activate and conda deactivate commands.
For bash or zsh, putting
export PATH="/opt/conda/bin:$PATH"
in your ~/.zshrc file puts your base environment on PATH, but doesn't necessarily actually activate that environment. Try removing that line and replacing it with
. ~/Anaconda3/etc/profile.d/conda.sh
conda activate base
as recommended in the official Anaconda 4.4.0 release notes.
Replace ~/Anaconda3 with the path where you installed Anaconda, if you put it somewhere else.
Running conda activate base puts the base environment on PATH and gives you access to the executables in the base environment.
Additional Resources:
Anaconda and JetBrains have a partnership. You can download the PyCharm IDE with Homebrew: brew cask install pycharm-ce-with-anaconda-plugin. Here is the link to the tap.
Official Anaconda documentation on installing for MacOS
Link to the canonical Homebrew cask for Anaconda
Official Anaconda 4.4.0 Release Notes
I am using Python 3.6. When I try to install "modules" using pip3, I face this issue:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
For Windows 10
if you want use pip in normal cmd, not only in Anaconda prompt. you need add 3 environment paths.
like the followings:
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
most people only add D:\Anaconda3\Scripts
MAC OS
I had the same problem on Mac OS(Mojave) and solved the problem as mentioned on this link - Openssl issue.
If you do not have Homebrew or don't know what is Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Or if you already have Homebrew installed:
brew update && brew upgrade
brew uninstall --ignore-dependencies openssl; brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Update:
Keep in mind, that I had to use --ignore-dependencies flag, because other packages installed that depend on OpenSSL.
Additional if the problem is caused after using pyenv, you can fix it by using:
brew reinstall python
For Debian users, the following may be of use:
sudo apt install libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev
Then cd to the folder with the Python 3.X library source code and run:
./configure
make
make install
I'm using Windows 10 and installed Miniconda 3 with Python 3.7.
I solved this error by following this https://github.com/conda/conda/issues/8273
Specifically, I copied the following files from C:\Users\MyUser\Miniconda3\Library\bin to C:\Users\MyUser\Miniconda3\DLLs:
libcrypto-1_1-x64.dll
libcrypto-1_1-x64.pdb
libssl-1_1-x64.dll
libssl-1_1-x64.pdb
For centos 7:
Install openssl:
sudo yum install openssl-devel
now goto python directory were we extracted the python tar,
run below commands
sudo ./configure
sudo make
sudo make install
This will fix the problem in centos...
For future Oracle Linux users trying to solve this, below is what worked for me.
First install missing libs:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
Then cd to your Python3.X library and run:
make
make install
macOS, pyenv
In case of your python being an pyenv installed one, where pyenv is installed with homebrew on macOS, there might me a newer version available which fixes this:
$ brew update && brew upgrade pyenv
Then reinstalling the python version:
$ pyenv install 3.7.2
pyenv: /Users/luckydonald/.pyenv/versions/3.7.2 already exists
continue with installation? (y/N)
Note, it is a bit dirty to overwrite the existing python install like that, but in my case it did work out. Probably cleaner to delete it and then recreate it properly.
For Windows 10,windows 7
If pip install is not working on CMD prompt, run it using Anaconda prompt - it works.
https://github.com/pypa/virtualenv/issues/1139
Worked for me.
sudo apt-get install libssl-dev
Use this to enable ssl for pip.
Let me know if someone encounters issues.
Encountered this issue while installing python 3.8 from source on ubuntu. The steps needed to install it successfully alongside the default python 3.7 are summarised below :
sudo apt -y install libssl-dev zlib1g-dev build-essential
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -xf Python-3.8.0.tgz
cd Python-3.8.0/
./configure --enable-optimizations
make
sudo make altinstall
The install instruction for zlib1g-dev and build-essential is redundant, as ubuntu desktop already has these, but was necessary for some of Amazon's EC2 instances. python 3.8.0 is the current release just now, but should be replaced with the latest available.
These instructions are best for keeping python 3.7 as the default for python3, and running python 3.8 in a virtual environment.
Similar to the above solution reinstall the python version with pyenv.
Somehow, I upgraded my openssl which broke the pyenv version python.
pyenv install 3.6.8
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
...
The first line says it relies on the homebrew openssl.
In my case, I reinstalled Python. It solved the problem.
brew reinstall python
For OpenSUSE in the same manner, but a few changes of listed above packages:
zypper install zlib-devel libopenssl-devel ncurses-devel sqlite3-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel
Then cd to Python sources dir and
make
make install
or
make
make altinstall
And perhaps
ln -s /usr/local/lib64/python3.6/lib-dynload/ /usr/local/lib/python3.6/lib-dynload
should be executed for OpenSUSE users. See Python 3.7 install not working on openSUSE Leap 42.3
Just try installing through Anaconda prompt
I ran into this issue with Visual Studio Code installing pylint from the VS Code prompt.
I was able to overcome the issue by opening the Anaconda installation directory and running
pip install pylint
Then VS Code was happy, but that did not fix the issue as running
& C:/Users/happy/Anaconda3/python.exe -m pip install -U pylint
pretty much gave the same error so it seems that VS Code is unable to access the python modules.
Note that VS Code picks up the first python env it see when installed, the bottom left of the screen indicates which env is being used. Clicking on that area allows to set the environment. So even if you ran the pip install for an environment VS Code could be looking at a different one.
Best approach was to make sure that VS code had the correct python environment selected and that same environment is in the system PATH (under System Properties --> Advanced --> Environmental Variables)
Under the Path Variable, Edit and browse to the specific Anaconda directory that you want VSCode to use and add to PATH, I needed to Add the following:
C:\Users\happy\Anaconda3\
C:\Users\happy\Anaconda3\Scripts\
C:\Users\happy\Anaconda3\Library\bin\
C:\Users\happy\Anaconda3\Library\mingw-w64\bin\
Your Anaconda installation directory may differ.
One note is that Windows does not have the PATH variable take effect until you restart the terminal. In this case close and re-op VS code. If using a Terminal or PS Shell then close and reopen and check Path to make sure it is included.
The problem probably comes from your installed openssl package version. That was the case for me and I fixed this issue just upgrading it. I'm on Mac OS, using brew :
brew upgrade openssl
If you installed python with brew, this should directly fix the issue with it, as python is dependent on openssl
Newest Python 3.8.4 or higher should able to support https protocol out of box. If you still have old python installation on your pc - either download & install python3 manually, or using Chocolatey:
If you don't have Chocolatey, install it - from here: https://chocolatey.org/docs/installation
You can just copy paste one command line liner and execute it from command prompt with elevated priviledges.
choco install python3
if you don't have python3 installed, or you you have it installed - then:
choco upgrade python3
Notice also that you can use also anaconda distribution, as it has built-in python with https support, but this rather ancient instructions, no need to follow them anymore.
Install anaconda, using command line:
choco install anaconda3
Set environment variables:
set PATH=C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3;C:\tools\Anaconda3\Library\bin;%PATH%
and then run command which failed. In my case it was:
pip install conan
Anaconda uses separate python installation, and pip is also anaconda specific.
As Tokci said, it also works for Windows 7.
"Go with the mouse to the Windows Icon (lower left) and start typing "Anaconda". There should show up some matching entries. Select "Anaconda Prompt". A new command window, named "Anaconda Prompt" will open."
Then pip works.
The following also helped to import xgboost:
https://www.youtube.com/watch?v=05djBSOs1FA
If someone is using Arch Linux OS, I solved the TLS/SSL problem by running this:
sudo pacman -S openssl
Then I could use pip to install the package I needed:
pip install openpyxl
Go to Anaconda prompt and type (if you have python 3.x installed on your engine) :
py -m pip install pymysql
i was having the same issue and this solved my problem. later after doing this you can import pymysql in power shell or any other prompt.
The issue is due to OpenSSL package is missing on your PC.
If pip install openpyxl also gives error.
you can fix this by installing OpenSSL(Win64 OpenSSL v1.1.1g) from below site :
slproweb.com/products/Win32OpenSSL.html
Restart the IDE you are using, for changes to be in effect.
In Windows 10 SQL Server 19 the solution is known.
Copy the following files:
libssl-1_1-x64.dll
libcrypto-1_1-x64.dll
from the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\Library\bin
to the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\DLLs
Then open a new DOS command shell prompt.
From https://learn.microsoft.com/en-us/sql/machine-learning/troubleshooting/known-issues-for-sql-server-machine-learning-services?view=sql-server-ver15#7-unable-to-install-python-packages-using-pip-after-installing-sql-server-2019-on-windows
Worked for me.
pkg install openssl
Use this to enable ssl.
Currently there is same issue in Anaconda prompt (Anaconda3) on Windows 10. Here is workaround: https://github.com/ContinuumIO/anaconda-issues/issues/10576
Fixed this without having to change anything related to TSL/SSL.
I was trying to see if the same thing was happening to pip, and saw that pip was broken. Did some digging and realized it's probably caused by Homebrew deleted python#2 on February 1st, 2020.
Running brew uninstall python#2 to delete python2 installed by Homebrew.
Destroyed the virtual env created using python3 and created a new one. pip3 installing works fine again.
I am on macOS and I had used brew but what Vaulstein mentioned in his answer didn't cover my case.
I run the following commands to make sure my current python was not installed by brew
brew list | grep python
python
python#2
brew info python
python#3.8: stable 3.8.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Not installed
...
So I download the latest 3.8.5 from https://www.python.org/ and when installing it I saw following information
Certificate verification and OpenSSL
This package includes its own private copy of OpenSSL 1.1.1. The
trust certificates in system and user keychains managed by the
Keychain Access application and the security command line utility are not used as defaults by the Python ssl module
After installed 3.8.5 it fixed the problem.
I got into this problem using Ubuntu, pyenv and Python 3.8.1 managed by pyenv. There was actually no way to get pip to work correctly, since every time I tried to install anything, including pip itself, the same error showed up.
Final solution was to install, via pyenv, a newer version, in this case 3.8.6. Apparently, from 3.8.4 Python is prepared to run SSL/TLS out of the box, so everything worked fine.
I simply solved the problem with following command:
brew upgrade python#3.9
SSL is included by default on this version!
In my case I was running into issues with my $PATH on Linux. This can also happen on MacOS.
Check to see if /usr/bin/pip3 install package_name_goes_here works for you. If so then run
which pip3 this will tell you which is the first directory that pip3 is installed in.
If it is something like /usr/local/bin/pip3 which is different from /usr/bin/pip3 then you may need to adjust your $PATH.
Run
echo $PATH and copy the result.
The PATH is simply a colon separated list of directories that contain directories. Bash will always return the first instance of the program that you are attempting to execute. Move all the system directories upfront. Here is a list of some of the system directories:
/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
If that fails then verify you have openssl installed by running openssl version -a if not then install openssl.
If you've installed anaconda via scoop, and encounter this error while using pip from within a conda environment you can resolve it by...
Adding these to your path
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Scripts
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library\bin
Installing openssl via scoop
scoop install openssl
And copying the following DLLs from ..\anaconda3\Library\bin to ..\anaconda3\DLLs
References:
https://stackoverflow.com/a/54897379
https://stackoverflow.com/a/60405693
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