A painting made from a photograph is known as a derivative work. But that doesn't mean you can simply make a painting from any photo you find — you need to check the copyright situation of the photo. Don't assume because the likes of Warhol used contemporary photos that it means it's okay if you do.
Who Holds the Copyright?
The creator of the photograph, i.e. the photographer, usually holds the copyright to the photo and unless they've expressly given permission for its use, making a painting based on a photo would infringe the photographer's copyright. In terms of US copyright law: "Only the owner of copyright in a work has the right to prepare, or to authorize someone else to create, a new version of that work." You may be able to obtain permission to use a photo for a derivative work from the photographer, or if you're using a photo library, buy the right to use it.
You might argue that the photographer is unlikely ever to find out if you use it, but are you going to keep a record of such paintings to ensure you never put it on display or offer it for sale? Even if you're not going to make commercial use of a photo, just by creating a painting to hang in your home, you're still technically infringing copyright, and you need to be aware of the fact. (Ignorance is not bliss.)
As for the argument that it's fine to make a painting from a photo provided it doesn't say "do not duplicate" or because 10 different artists would produce 10 different paintings from the same photo, it's a misconception that photos aren’t subject to the same stringent copyright rules as paintings. It seems that all too often artists who would scream if someone copied their paintings, don’t hesitate to make a painting of someone else’s photo, with no thought to the creator’s rights. You wouldn't say "as long as a painting doesn't say 'do not duplicate' that anyone can photograph it and declare it their original creation".
The absence of a copyright notice on a photo doesn’t mean copyright doesn't apply. If a copyright statement says ©2005, this doesn’t mean that copyright expired at the end of 2005; it generally expires several decades after the creator’s death.
What Is Copyright?
According to the United States Copyright Office, "Copyright is a form of protection provided by the laws of the United States (title 17, U.S. Code) to the authors of 'original works of authorship,' including literary, dramatic, musical, artistic, and certain other intellectual works.....Copyright protection subsists from the time the work is created in fixed form." Copyright gives the creator (or the creator's estate) of an original work exclusive rights to that work as soon as it is created, for a duration of seventy years following the death of the creator (for works created after January 1, 1978).
Due to the Berne Convention for the Protection of Literary and Artistic Works, an international copyright agreement that originated in Berne, Switzerland in 1886 and adopted by many countries over the years, including the United States in 1988, creative works are automatically copyrighted as soon as they are "in fixed form," meaning that photographs are copyrighted as soon as the picture is taken.
How to Avoid Copyright Infringement Issues
The easiest solution to avoiding copyright infringement issues when painting from photos is to take your own photos. Not only do you not run any risk whatsoever of copyright infringement, but you have complete creative control over the entire artistic process, which can only benefit your art making and painting.
If taking your own photos is just not possible, you can also use the Artist's Reference Photos, photos from somewhere such as Morgue File, which provides "free image reference material for use in all creative pursuits", or combine several photos for inspiration and reference for your own scene, not copy them directly. Another good source of photos is those labeled with a Creative Commons Derivatives License in Flickr.
A photo that is labeled "royalty-free" in photo libraries is not the same as "copyright free". Royalty free means that you can buy the right from the copyright holder to use the photo wherever you want, whenever you want, however many times you want, rather than purchasing the right to use it once for a specific project and then paying an additional fee if you used it for something else.
Disclaimer: The information given here is based on US copyright law and is given for guidance only; you're advised to consult a copyright lawyer on copyright issues.
Bamberger, Alan, Copy or Borrow From Other Artists? How Far Can You Go?, ArtBusiness.com, http://www.artbusiness.com/copyprobs.html.
Bellevue Fine Art Reproduction, Copyright Issues for Artists, https://www.bellevuefineart.com/copyright-issues-for-artists/.
United States Copyright Office Circular 14, Copyright Registration for Derivative Works, http://www.copyright.gov/circs/circ14.pdf.
United States Copyright Office Circular 01, Copyright Basics, http://www.copyright.gov/circs/circ01.pdf.