我在Ubuntu 22.04.4上使用Python 3.10,我试图运行我最初在Windows 11机器上编写的代码.每当我运行这个脚本——main.py
——它总是停止在导入阶段,尤其是导入beautifulsoup4
和yfinance
失败:
print("Starting imports.")
import pandas
print("Imported pandas...")
from bs4 import BeautifulSoup
print("Imported beautifulsoup4...")
import yfinance as yf
print("Imported yfinance...")
# Rest of code...
当我在终端中运行这个脚本时,它只打印Starting imports. Imported pandas...
个.在这篇文章之后,它吐出了Illegal instruction (core dumped)
:
(myenv) minime@Shaguar:~/Coding/WebScraping$ python main.py
Starting imports.
Imported pandas...
Illegal instruction (core dumped)
我对这个"非法指令"错误做了一些研究,并遇到了由于不兼容的CPU架构而导致的TensorFlow、numpy和其他错误的导入失败,但我不知道在这种情况下它将如何适用于beautifulsoup4.
如何成功导入beautifulsoup4
和yfinance
而不会出现Illegal instruction (core dumped)
错误?
(建筑输出lscpu
):
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 36 bits physical, 48 bits virtual
Byte Order: Little Endian