Skip to content

Instantly share code, notes, and snippets.

@farhad0085
Last active October 18, 2024 15:42
Show Gist options
  • Select an option

  • Save farhad0085/13c13ff61236aab04672ec1f8fa366ed to your computer and use it in GitHub Desktop.

Select an option

Save farhad0085/13c13ff61236aab04672ec1f8fa366ed to your computer and use it in GitHub Desktop.
  1. First install nodejs and npm.

    sudo apt-get install nodejs npm
    
  2. Now clean the cache of npm first:

    sudo npm cache clean -f
    
  3. Install n module of npm:

    sudo npm install -g n
    
  4. Begin the installation by selecting the version of node to install: stable or latest or specific version number:

    sudo n stable
    

    or

    sudo n 12.18.2
    

    Current LTS version

    sudo n 16.15.1
    
  5. Check the version of node:

    node -v
    
  6. Check the version of npm:

    npm -v
    

This is going to be beyond the scope of the tutorial. However here is how you could install a specific version if needed:

First, install the required libraries:

sudo apt-get install libssl-dev openssl make gcc

Then choose the specific Python from here:

https://www.python.org/ftp/python/

After that go to the /opt directory and download the archive of the specific version:

cd /opt
wget https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz

Extract the archive:

tar xzvf Python-3.9.2.tgz

Then cd into the directory:

cd Python-3.9.2

And finally, compile the new version:

./configure --enable-optimizations
make
make install

Finally you can create a symlink for that specific Python version so that you could use the binary from anywhere:

sudo ln -fs /opt/Python-3.9.2/Python /usr/bin/python3.9

Then you could check if the python3.9 version is available:

python3.9 --version

Remove python2

sudo apt purge -y python2.7-minimal

Or if you don't sure about python2 version

sudo apt purge -y python2.*

You already have Python3 but don't care about the version

sudo ln -s /usr/bin/python3 /usr/bin/python

Same for pip

sudo apt install -y python3-pip
sudo ln -s /usr/bin/pip3 /usr/bin/pip

Confirm the new version of Python: 3

python --version

Reference: https://stackoverflow.com/a/60590067

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment