[Fixed]-How to install pygments on Ubuntu?

28👍

Most basically open a terminal with CtrlAltt and type sudo apt-get install python-pygments. That will work but there is a better way, which I’ll explain.

When you’re developing a web app you will eventually want to deploy it. You’ll want the environment on which you’re developing to be as similar to the one on which you deploy as possible. One way to do this is virtual environments. On Ubuntu you also have the option of Docker.

Virtual environments are probably slightly easier if you’re just starting out but I would recommend building up to Docker, which is more complete IMO. If you’re using Python 3 then you should use pyvenv to create your virtual environments. On Python 2 you want virtualenv. These will create an isolated Python environment specific to the project they contain, which means you can have many custom setups for many projects, and you can recreate these relatively easily when deploying to production. When the environment is active you can install python packages with pip install package-name-here.

12👍

For Python3, you can install it with sudo apt-get install python3-pygments

As we traditionally use a virtual environment to run Django, you may also want to install it through pip

4👍

I installed via apt-get install python-pygments , but it didn’t solve my ImportError: No module named pygments.

But pip install Pygments solved my problem.

👤HarryQ

Leave a comment