1

this question is specifically for aws cloud9. Everything looks fine prima-facie, but it's creating a lot of problems.

When i am checking python version, it's showing the correct version (without using python3)

[email protected]:~/environment $ python --version
Python 3.6.8

When i am using which python, it's showing the correct (desired) python version

[email protected]:~/environment $ which python
alias python='python36'
        /usr/bin/python36

When i am checking pip version, it's showing pip version for python 3.6, but showing a very old version of pip.

[email protected]:~/environment $ python -m pip --version
pip 9.0.3 from /usr/lib/python3.6/dist-packages (python 3.6)

When i try to upgrade pip to new version, it goes to python2.7 now (undesirable)

[email protected]:~/environment $ pip install --upgrade pip
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages (20.0.2)

so, when i do a pip install of a desired package, it gets installed, but cannot use it in my program as it installs for python 2.7.

I have gone past this issue on my local windows computer a long time ago. However, this is a ec2 default environment that comes when setting up cloud9, and is a linux ubuntu dist (afaik).

Have tried to find out online, but couldn't get a simple answer. I could find answers relating to using virtualenv for these kind of issues. I am wondering if there is a simpler solution to this.

3
  • Do you have pip3 or pip-3.6 binaries; Instead of using python -m pip --version use pip --version which python version do you see ? Commented Feb 5, 2020 at 13:00
  • [email protected]:~/environment $ pip --version pip 20.0.2 from /usr/local/lib/python2.7/site-packages/pip (python 2.7) Commented Feb 5, 2020 at 13:06
  • You will have to add an alias for pip to point to pip3 Commented Feb 5, 2020 at 13:06

2 Answers 2

3

I finally resolved it by unaliasing "python" with python36. unalias python

Then when i went to ask python version, it gave python 2.7 (as expected)

then i went for sudo python3 -m pip install --upgrade pip

it finally worked and upgraded pip to latest.

then i could download other libraries using python3 -m pip install <library-name>

Thanks Arun for your extensive help.

This solution may be a workaround, but it finally made it work. If anyone wants me to find the solution further, i am ready to engage.

Sign up to request clarification or add additional context in comments.

Comments

1

python is an alias to point to python36. Looks like you have python 2 and python 3 installed.

python -m pip --version is returning the pip version pointing to python3 because python here refers to python3. If you try python2.7 -m pip --version it will return the pip version corresponding to python2.7

You should rather check pip --version to see the version of pip.

You could install your packages using pip3 install <package-name> or set an alias for pip to point to pip3

which pip3

Once you get the path of pip3, then you can create the alias

alias pip=`<path to pip3>

12 Comments

actually, i had tried using pip3, but it didn't work. checked using your command "which pip3" -------------- [email protected]:~/environment $ which pip3 /usr/bin/which: no pip3 in (/home/ec2-user/.nvm/versions/node/v10.18.1/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3/bin:/home/ec2-user/.rvm/gems/ruby-2.6.3@global/bin:/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin:/usr/local/bin:/bin:/usr/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin:/home/ec2-user/.rvm/bin:/.......
What is the output of pip3? Is pip3 binary not present ? Maybe you have pip3.6 instead of pip3 ? python3.4 and above ship pip by default. You could alternatively try python -m pip install <package> this will install packages for python3.6
pip3 gives an error that command not found. However, python -m pip install <package> may work because i tried it and it didn't give any error..
python -m pip install <package> will definitely work. Try checking for pip3.6 binary
however.. now the problem is that the pip3.6 is an older version - 9.0.3 - and when i am trying to upgrade it using python - m pip install --upgrade pip.. it doesn't work..
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.