Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write the requirements.txt file with "--no-binary"?

Tags:

python

pip

I have to install the python package in the following way,

pip install --no-binary=protobuf protobuf

But How to write requirements.txt with --no-binary=protobuf?

like image 315
caimaoy Avatar asked Jan 15 '19 08:01

caimaoy


People also ask

Do you have to specify version in requirements txt?

No, there is no need to specify a version. It's probably a good idea to specify one, though. If you want to specify a version but you don't know which version to specify, try using pip freeze , which will dump out a list of all the packages you currently have installed and what their versions are.

Where do I put the requirements txt file?

Typically the requirements. txt file is located in the root directory of your project. Notice we have a line for each package, then a version number. This is important because as you start developing your python applications, you will develop the application with specific versions of the packages in mind.


Video Answer


1 Answers

Turning my comment into an answer:

pip supports reading options from requirement files. This means that a requirements file

protobuf
--no-binary=protobuf

is a valid requirements line, same as e.g. a file consisting out of a single line

protobuf --no-binary=protobuf

This means that you can also reference other requirement files, e.g.

# requirements.txt
-r test_requirements.txt
spam eggs

Note, however, that pip install -r requirements.txt is roughly equivalent to running cat requirements.txt | xargs pip, so the options are applied to the whole command and not a single line or file. For example, this file defines conflicting options:

# requirements.txt
spam --no-binary=eggs
bacon --only-binary=eggs

An attempt of installing from this requirements file will lead to an error.

like image 115
hoefling Avatar answered Oct 18 '22 19:10

hoefling