I have installed SP 2007 with a lot of custom web parts. Now I would like to migrate to SP 2010.
What is the best way to migrate custom web parts from SP 2007 to 2010? What I need to make it work? Can I (some how) import web parts from SP 2007 instance to 2010 instance?
What if I have no source code for some web parts? Can I migrate them to new instance?
That would depend entirely on what the web parts do and what parts of SharePoint they interact with. The best way to start on this path is to stand up a SP2010 Dev environment and then install and deploy the web parts there, then migrate the content databases that use the web parts there as well. After that you should have an immediate pass/fail of whether or not the web parts will work at all. If they work, you would now have a way to compare their functionality side-by-side with the how they work in 2007.
If you do not have the source code and there is an error in how they render in the 2010 dev environment, then it is entirely possible that you will have to find alternatives to those web parts.
All web parts should be deployed as a solution (WSP) directly in SharePoint. If you have web parts that were deployed manually then they should be either rewritten or abandoned. You can easily extract the WSP files from SharePoint and then install those into your 2010 environment.
in Powershell, you can extract copies of the WSP files like this: