Portuguese President Antonio Ramalho Eanes swore in a new non-party government today and said it could still prepare the way for a stable parliamentary majority.

But he said if parliament rejected the program of Prime Minister Carlos Mota Pinto, 42, a law professor, then the alternative was a government charged with preparing new elections.

Eanes said the new government, portugal's 10th since the 1974 revolution, took office in the deepest crisis faced so far by the young democracy. He called for competence and efficiency in meeting Portugal's grave economic and social problems.

"Unfortunately, this government will have to pursue for some time to come the policy of austerity which we are all ready feeling in daily life," Eanes said.

Mota Pinto acknowledged the challenge at the swearing-in ceremony.

"The nation must learn to produce and to live with what it produces," Mota Pinto said. "We cannot continue to spend our meager hard currency reserves for unnecessary things."

He said the government's 1978 budget deficit, including the nationalized industrial sectors, would top $2 billion.

Portugal imports half its basic foodstuffs and faces a crippling balance of payments deficit that reached $1.5 billion in 1977.

The Communist Party has already given notice that it will seek to oust the new government. Former Prime Minister Mario Soares has described the Mota Pinto Cabinet as the most conservative since 1974.