Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import requirements.txt from an existing project using Poetry

I am trying out Poetry in an existing project. It used pyenv and virtual env originally so I have a requirements.txt file with the project's dependencies.

I want to import the requirements.txt file using Poetry, so that I can load the dependencies for the first time. I've looked through poetry's documentation, but I haven't found a way to do this. Could you help me?

I know that I can add all packages manually, but I was hoping for a more automated process, because there are a lot of packages...

like image 280
Felipe Avatar asked Jul 06 '20 20:07

Felipe


People also ask

Can poetry use requirements txt?

But yeah, poetry doesn't have a command to import requirements. txt . You can use dephell, but I don't know how good or reliable that is.

How do I install all requirements from requirements txt?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.


1 Answers

poetry doesn't support this directly. But if you have a handmade list of required packages (at best without any version numbers), that only contain the main dependencies and not the dependencies of a dependency you could do this:

$ cat requirements.txt | xargs poetry add 
like image 108
finswimmer Avatar answered Sep 28 '22 05:09

finswimmer