Yes, it is possible to run for president from prison. Eugene V. Debs ran for president five times with the Socialist Party, and the fifth time in 1920, he did so while behind bars. He had been arrested for giving a speech in Ohio in 1918 criticizing US involvement in WWI, wherein he said that the working class “make the sacrifices…” and “shed the blood [but] have never yet had a voice in declaring war.” The US had amended the Espionage Act just a few weeks earlier to limit speech critical of the war, and two federal officers in the crowd that day photographed Debs giving his speech, leading to his sentencing to 10 years in a federal prison. Despite this, the Socialist Party still picked him as their candidate in 1920, and he managed to win almost 1 million votes, more votes by raw number than any Socialist Party candidate in history. The winner of that election, Warren G. Harding, released Debs early in 1921, the same year Congress got rid of the amendment limiting anti-war speech.