skip to Main Content

I’m trying to install 2 packages that were no issue on Anaconda virtual environment. But on an AWS EC2 instance of Ubuntu (v24.04 LTS GNU/Linux 6.8.0-1010-aws x86_64), it’s not working.

Typically i would just run pip3 install langchain and pip3 install langchain-community but i get the error that this is an ‘externally managed environment’

I have installed most packages on this machine like this:

sudo apt install python3-PACKAGEXYZ

But even that comes with error:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package python3-langchain

Same for installing sudo apt install python3-langchain-community

Can someone please tell me the correct commands to install langchain and langchain-community on Ubuntu?

2

Answers


  1. Either create virtual environment for python or remove External managed
    Run this command then you will be able to install through pip

    rm /usr/lib/python*/EXTERNALLY-MANAGED

    Update: This command can break your system.

    Login or Signup to reply.
  2. make a viertual environment IN Ubuntu on EC2? I do this on Windows as i have multiple python versions and projects. But this Ubuntu machine on Amazon EC2 is only for one Pyhton version and a single project only. I’ve managed to install a few python modules already using the sudo apt install command above.

    Yes, make a virtual environment for your project on the EC2 machine, even if it’s for only one Python version and a single project. It will also make it simpler for you in the long run to remember how to install the dependencies, because it’s the same thing both on your Windows dev box(es) and in production: create a venv, install requirements.

    While you can certainly install some Python modules from the Ubuntu package repository archives, they will not have packaged everything, and they may not be the versions your project requires. For instance, the version of, say, Weasyprint, a package for creating PDFs, is 61.1 on Ubuntu 24.04, but the current version on PyPI is 62.2.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search