Terminal and python

I am trying to follow the lesson on the video below but I am finding that difficult.


I have a Mac book that has been pre-install by python 2.7 and then I downloaded python 3.8. I am able to use the python3 command to enter the python3 ‘interface’, but the problem is that after trying to follow the instructions of the video, and getting the exact error message about the path and trying to fix it with the instructions provided, I still get the message that pipenv is not recognized.
One thing I notice is that my shell is zsh as I always get a message from the terminal that zsh is now the new shell for OS Catalina but even when I tried changing the shell to bash, the problem still wasn’t solved. Here is
Look at the following pictures:

Screenshot 2020-05-22 at 11.12.48

So zsh profile. Next, if I type pip --version, it should that the pip is installed in the python 2.7 version.

Screenshot 2020-05-22 at 11.15.46

Next, if I type python --version it shows the python2 version, similarly for python3, so it recognizes that I have both and they can coexist without problem.

Screenshot 2020-05-22 at 11.17.45

Now if after installing pipenv and trying to get the version, it will return an error message.

Screenshot 2020-05-22 at 11.19.14

I have attached a picture of the file path:

Screenshot 2020-05-22 at 11.21.06

One thing I notice is that the installing was done on the python 2.7 version and not 3.8. pipenv and other libs e.g. jupyter and such that I have tried to download also return similar error.

When I type this vi ~/.bash_profile, I got the following message:

Screenshot 2020-05-22 at 11.26.48

So as a beginner everything seems so confusing and all over the place. I would really appreciate a step-by-step help about how to fix everything. Also, is it possible that when I open my terminal, it automatically runs python3 instead of python2?

I hope this question is detailed enough.

yeah well which one of them did you ask to do the installation?

The instructions say on python3 but I am not sure I understand how to make it happen?
Do I have to first go in python3 mode and install that? I tried that and all I keep getting was error either when trying to install pip or pipenv.
I might be doing something wrong so please feel free to correct me.

there are no modes, you have two completely separate things, same as you have many other programs installed, they too do not interfere with one another
so if you don’t run the things from python2 then you won’t be touching python2

you established that pip belongs to python2, so you wouldn’t touch it. where’s python3’s pip? use that one.

So you would not add python2-owned directories to your path.

And you probably wouldn’t be touching .bash_profile if you’re not using bash

I think this is where the lies. I do not understand what you mean by that, but I assume it means that I have to install pip for python3. I am not sure I can do that. Most things that I found online with the searches just mention installing pip on mac or windows but wasn’t version-specific.

You’re expected to target your installation of python whichever one you mean that is, that part is specific to you.
So you would look at the intention of what is done, adapt that to what you have. If you copy something and run it then it’s probably not going to mean the same thing on your end.

$ python3 -m pip --version

You simply wouldn’t touch any of the system-installed python. Whatever you do use has to be part of the python you installed.

When I ran the code, I got:

Screenshot 2020-05-22 at 13.56.20

So, I assume pip does exist on the python3 as well.
But in my error message when running the pipenv, the file path was referencing python 2.7 as the path instead of this.
The error was saying that the files were installed in python 2.7

If you installed it for python 2 then that’s what it would operate on.

If you think of your two installations as two separate languages then you have the right idea. Don’t expect one to work for the other, and you’re fine. Don’t expect anything to choose the right one for you. You have to target the one you meant. From their perspective, there is only one python, there’s no choice to be made, you already chose.

I understand what you are trying to say but since I am a newbie its difficult to understand what to do in some cases. Look at the picture below:

When he enter the pip --version into the shell, the response was python3.7 unlike mine that responded with python2.7. Now, if I try to use the python3 at the start of the command to install the pip it returns and error message.
This is where I find it difficult, I think what I need is a code that install pip on python3 and it gets more confusing because the last picture return a pip 19.2.3 as the version on python3, but then if I try to do anything there it doesn’t work.

what does that even mean, and, do you really mean to install pip? thought you already determined that it is installed. more likely you’d want to install pipenv

maybe it says something about what the problem is. if you’ve decided that this is the action you want to do, then you’d fix whatever is wrong here and then do it again

that’s a phrase you’ll probably want to stop using, there’s usually some relevant information in terms of what you expected and what you got instead, “doesn’t work” is a way of avoiding looking at the situation, if you for example don’t end up with being able to type pipenv and instead get no match or the wrong version, then you would consider whether the right version exists somewhere and what determines what you get when you write a command, which is your PATH variable, the solution to that would as such be to both make sure it is installed, and that the PATH variable includes the directory of that executable and that this directory comes before any other containing other matches that you don’t want

Anyway, since python lets you run modules through the python executable like shown above with pip, you could reach both pip and pipenv through that.

I was finally able to solve the problem.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.