Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with pip3 and pipenv with Mac OS Catalina fresh install

I installed xcode dev tools first using

%xcode-select --install

then I installed Homebrew using

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then I did

%brew install python3

%pip3 install pipenv

but when I call

%pip3

I get

% pip3
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/usr/bin/pip3", line 10, in <module>
    sys.exit(main())
TypeError: 'module' object is not callable

This is where it says my pip3 and python3 are located

% which pip3
/usr/bin/pip3

% which python3
/usr/bin/python3

Can someone please help me solve this problem. I am trying to learn to program but I can't continue without fixing this

like image 883
MRS_ROBOT Avatar asked Dec 04 '22 17:12

MRS_ROBOT


1 Answers

MacOS Catalina ships with it's own versions of python3 and pip3, so this is probably conflicts between macOS and Brew-installed Python libraries. I solved similar issues by no longer using Brew for anything related to Python.

My recommendation: From a fresh install of Catalina, run sudo pip3 install pipenv. Create a separate directory for each project you work on, and run pipenv shell from that directory every time you work on it. Don't ever bother installing any packages system-wide, and don't overwrite macOS's Python. Anything you do, do inside a Pipenv managed virtual environment -- only install packages via pipenv install <pkg>.

Doing all this will keep the right version of the Python binary and all related packages inside a directory inside ~/.local/share/virtualenvs/ for each project. This way, future macOS updates shouldn't every break dependencies.

like image 86
Mickey Ristroph Avatar answered Dec 28 '22 10:12

Mickey Ristroph