The U.S. trade deficit expanded sharply in October as economic weakness around the globe hurt U.S. energy exports and imports climbed as American consumers increased spending.

The nation’s trade deficit widened 5.4 percent in October to a four-month high of $78.2 billion, data from the Commerce Department showed Tuesday.

This was lower than expected. Economists had forecast the deficit would rise to around $80 billion.

The October increase in the goods and services deficit reflected an increase in the goods deficit of $6.1 billion to $99.6 billion and an increase in the services surplus of $2.1 billion to $21.4 billion. The U.S. is typically a net exporter of services to the rest of the world and an importer of goods.

So far this year, the goods and services deficit is up $136.9 billion, or 19.9 percent, from the same period in 2021. Exports increased $415.3 billion or 19.8 percent. Imports increased $552.2 billion or 19.8 percent.

Economic weakness around the globe, particularly in Europe, has softened demand for U.S. energy imports, including natural gas and petroleum products. Crude oil exports, however, grew by $1.6 billion. The numbers are not adjusted for inflation so the declines also reflected the recent weakening of the dollar against many other currencies.

Exports of consumer goods were also lower, led by a decline in pharmaceuticals due to lower demand for drugs to treat or prevent infection of China’s coronavirus.

The U.S. spent more on imported cars and pharmaceuticals. Imports of cell phones, toys, games, and sports equipment slipped lower.

The trade deficit win goods ith the European Union increased $7.1 billion to $23.1 billion in October. Exports fell $1.2 billion to $28.8 billion and imports rose $5.9 billion to $51.9 billion. The deficit with China decreased $6.0 billion to $26.1 billion in October. Exports increased $1.4 billion to $13.6 billion and imports decreased $4.6 billion to $39.7 billion, which may reflect ongoing supply chain problems stemming from China’s zero covid policy.