||This article includes a list of references, related reading or external links, but its sources remain unclear because it lacks inline citations. (February 2013)|
In June 1788, Pym joined the Royal Navy as captain's servant of the frigate Eurydice. He was promoted to lieutenant of the sloop Martin, under Captain William Grenville Lobb, and served under Lobb aboard the Babet and the Aimable.
In 1810, Pym was sent to the Isle de France (now Mauritius) to lead a squadron consisting of the frigates Sirius, Iphigenia Nereide, and the brig Staunch. On 13 August, the squadron captured the Île de la Passe which commanded the entrance of Grand Port, and moved to blockade Port Louis. On 21 August, the squadron seized the East Indiaman Wyndham, previously captured by the French, and learnt that a French frigate squadron had arrived at Grand Port.
The British squadron attempted to attack the French squadron at anchor and moved into the harbour. Entering it, the Sirius and Magicienne ran aground and became unmanoeuverable. The Nereide struck her colours before the French frigates, and the Sirius and Magicienne were scuttled by fire. The last ship of the squadron, the Iphigenia, surrendered two days later. Pym, then at the Île de la Passe, was taken prisoner along with the whole garrison. The Battle of Grand Port became the only defeat of a British squadron against Napoleonic France. Pym was released in December when Sir Albemarle Bertie recaptured the Île de la Passe. He was court-martialled and found innocent of the defeat.
Pym was made a rear-admiral in 1837. He served as admiral-superintendent at Devonport, from 1841 to 1846, and in the autumn of 1845 commanded the experimental squadron in the Channel. He was promoted to vice-admiral in 1847 and to full admiral in 1851.