You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Keep getting "operation not permited" Erorr when running terminal commands

Whenever I run commands such as pip3 or other commands in the terminal, I get a "Operation Not permitted" error. Here is an example:


(base) lukasr@MacBook-Air-95 ~ % pip3 install currencyconverter

Defaulting to user installation because normal site-packages is not writeable

WARNING: Ignoring invalid distribution -hiboken2 (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

WARNING: Ignoring invalid distribution - (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

WARNING: Ignoring invalid distribution -hiboken2 (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

WARNING: Ignoring invalid distribution - (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

Collecting currencyconverter

Downloading CurrencyConverter-0.16.12-py2.py3-none-any.whl (547 kB)

|████████████████████████████████| 547 kB 8.7 MB/s

WARNING: Ignoring invalid distribution -hiboken2 (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

WARNING: Ignoring invalid distribution - (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

Installing collected packages: currencyconverter

ERROR: Could not install packages due to an OSError: [Errno 1] Operation not permitted: '/Users/lukasr/Library/Python/3.8/lib/python/site-packages/currency_converter'


WARNING: Ignoring invalid distribution -hiboken2 (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

WARNING: Ignoring invalid distribution - (/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages)

(base) lukasr@MacBook-Air-95 ~ %



Also everytime I open my terminal I get these warnings.

Last login: Mon May 9 09:39:11 on ttys000

You have new mail.

/Users/lukasr/.zprofile:6: no such file or directory: /opt/homebrew/bin/brew

zsh: locking failed for /Users/lukasr/.zsh_history: operation not permitted: reading anyway

touch: /Users/lukasr/.zsh_sessions/2F950EF6-80D6-4336-954E-F1ACCCFEA9D3.historynew: Operation not permitted



Please can anybody suggest anything to help. Even if you are not sure if it is helpful share it with me.


[Personal Information Edited by Moderator]




MacBook Air 13″, macOS 10.15

Posted on May 9, 2022 12:53 PM

Reply
Question marked as Top-ranking reply

Posted on May 10, 2022 10:10 AM

You need to be careful with your PATH settings if you have Apple's Xcode, or Command-Line tools installed, because not only do they install /usr/bin/python3, but also /usr/bin/pip3. Alternatively, a Python3 installed via Python.org's installers places soft links in /usr/local/bin for python3 and pip3 that are linked back to /Library/Frameworks/Python.framework/Versions/3.8/bin.


Without altering your PATH to access the pip3 command in /usr/local/bin, your defaulting to /usr/bin/pip3 will attempt to install the currencyconverter module into Apple's Python3 system library location, and that will fail. Once you have adjusted your PATH to access /usr/local/bin before /usr/bin, then the pip3 install -U currencyconverter command should succeed as the module will be written into /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages.

Similar questions

10 replies
Question marked as Top-ranking reply

May 10, 2022 10:10 AM in response to FrequentIdea

You need to be careful with your PATH settings if you have Apple's Xcode, or Command-Line tools installed, because not only do they install /usr/bin/python3, but also /usr/bin/pip3. Alternatively, a Python3 installed via Python.org's installers places soft links in /usr/local/bin for python3 and pip3 that are linked back to /Library/Frameworks/Python.framework/Versions/3.8/bin.


Without altering your PATH to access the pip3 command in /usr/local/bin, your defaulting to /usr/bin/pip3 will attempt to install the currencyconverter module into Apple's Python3 system library location, and that will fail. Once you have adjusted your PATH to access /usr/local/bin before /usr/bin, then the pip3 install -U currencyconverter command should succeed as the module will be written into /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages.

May 9, 2022 2:14 PM in response to FrequentIdea

FrequentIdea wrote:

Whenever I run commands such as pip3 or other commands in the terminal, I get a "Operation Not permitted" error. Here is an example:

(base) lukasr@MacBook-Air-95 ~ % pip3 install currencyconverter




https://www.activestate.com/resources/quick-reads/how-to-install-and-use-pip3/


https://stackoverflow.com/questions/34573159/how-can-i-install-pythons-pip3-on-my-mac


Install pip3 on Mac | Delft Stack


May 9, 2022 11:19 PM in response to leroydouglas

Whenever I try: sudo python3 get-pip.py, I get this error

ERROR: Could not install packages due to an OSError: [Errno 1] Operation not permitted: '/Users/lukasrois/ve/lib/python3.9/site-packages/wheel'


and homebrew never seems to work for me, always different errors like:


brew install python3

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!


brew install pip3

Error: No previously deleted formula found.

Error: No formulae found in taps.

May 10, 2022 9:49 AM in response to FrequentIdea

FrequentIdea wrote:

and homebrew never seems to work for me, always different errors like:

brew install python3
Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)!

brew install pip3
Error: No previously deleted formula found.
Error: No formulae found in taps.

This tells you that you must install it differently on an M1 Mac. Check the Homebrew website for details on how to properly install Homebrew on an M1 Mac and how to install pip3 and/or Python on an M1 Mac.


Keep in mind if you are using an M1 Mac, then not everything in Homebrew may be fully compatible with an M1 Mac. You need to check the Homebrew website for compatibility information on the packages you wish to install.

May 11, 2022 4:43 AM in response to FrequentIdea

Using the Zsh (~/.zshrc) or Bash (~/.bash_profile) dot files in your home directory, and your favorite text editor, you can alter the order of paths as I have shown below. The PATH statement on its own places /usr/bin before /usr/local bin and this is reversed below:


export PATH=".:$HOME/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:${PATH}"


If you want that PATH to change in the current Terminal sessions, and not on the next Terminal launch, then do the following depending on your SHELL in use:


source ~/.zshrc
# or
source ~/.bash_profile


Keep getting "operation not permited" Erorr when running terminal commands

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.