4

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

MRS_ROBOT
  • 107
  • 1
  • 10
  • Does this answer your question? [Trouble installing TextBlob with pip](https://stackoverflow.com/questions/58442401/trouble-installing-textblob-with-pip) – phd Dec 08 '19 at 11:53
  • https://stackoverflow.com/search?q=%5Bpip%5D+TypeError%3A+%27module%27+object+is+not+callable – phd Dec 08 '19 at 11:53

3 Answers3

12

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.

Mickey Ristroph
  • 571
  • 1
  • 5
  • 11
  • I ended up downloading high sierra instead of Catalina. But I will keep this in mind if I switch back to Catalina – MRS_ROBOT Dec 11 '19 at 04:01
4

I had a similar problem after upgrading to Catalina since I was already using homebrew and Python/pipenv stopped to work as expected. My Python crashed every time, I ran pipenv install with an error described in this developer.apple.com thread. The answer by Mickey Ristroph sounds like a okay'ish workaround, but it doesn't really solve the problem.

I want to be able to use homebrew for all my MacOS installed software - including Python. But there was help, since the problem was the usage of a wrong version libcrypto dylib version. To fix the issue, update & upgrade brew packages and be sure openssl is installed:

brew update && brew upgrade && brew install openssl

Then we create new symbolic links to the homebrew installed libssl.dylib and libcrypto.dylib libraries:

# go to homebrew installed openssl dir:
cd /usr/local/Cellar/openssl/1.0.2t/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/

cd /usr/local/lib
# if there are links already, you may backup them:
mv libssl.dylib libssl_bak.dylib
mv libcrypto.dylib libcrypto_bak.dylib

# now create new symbolic links:
sudo ln -s libssl.1.0.0.dylib libssl.dylib
sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib

Now my homebrew installed Python (and pipenv) works like a charm again.

jonashackt
  • 12,022
  • 5
  • 67
  • 124
2

You need to change the raw command used to install libraries and supports in macOS Catalina to this:

python3 -m pip install pipenv  

(instead of pip3 install pipenv)

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
vijay9908
  • 59
  • 2