Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Python requirements file have to specify version?

I have a requirements.txt file for a Python code base. The file has everything specified:

pytz==2017.2 requests==2.18.4 six==1.11.0 

I am adding a new package. Should I list its version? If yes, how do I pick a version to specify?

like image 636
Intrastellar Explorer Avatar asked Mar 07 '19 20:03

Intrastellar Explorer


People also ask

How does Requirements file work in python?

A requirements file is a list of all of a project's dependencies. This includes the dependencies needed by the dependencies. It also contains the specific version of each dependency, specified with a double equals sign ( == ). pip freeze will list the current projects dependencies to stdout .

What should requirements txt contain?

In Python requirement. txt file is a type of file that usually stores information about all the libraries, modules, and packages in itself that are used while developing a particular project. It also stores all files and packages on which that project is dependent or requires to run. Typically this file "requirement.

Could not find a version that satisfies the requirement OS from versions none?

Solution 1: Just update pip You just need to update pip and your error will be resolve. Just follow this command. If you are windows users Then run this command. And then also upgrade setuptools after doing the above.


1 Answers

Check out the pip docs for more info, but basically you do not need to specify a version. Doing so can avoid headaches though, as specifying a version allows you to guarantee you do not end up in dependency hell.

Note that if you are creating a package to be deployed and pip-installed, you should use the install-requires metadata instead of relying on requirements.txt.

Also, it's a good idea to get into the habit of using virtual environments to avoid dependency issues, especially when developing your own stuff. Anaconda offers a simple solution with the conda create command, and virtualenv works great with virtualenvwrapper for a lighter-weight solution. Another solution, pipenv, is quite popular.

like image 198
Engineero Avatar answered Oct 14 '22 17:10

Engineero