如果我尝试使用请求html模块,我将得到错误zsh:非法硬件指令。
我通过在Python上创建一个虚拟环境解决了这个问题。如果将包括request-html在内的模块安装到虚拟环境中,则错误将消失。
自上个月以来,我一直在使用Apple M1,但我从未见过这种行为。
我的设置如下:
1 - I have [Pyenv][1], a python version manager.
2 - I always use a virtual environment, since you should avoid
installing libraries and changing the root python in your computer.
3 - I have requests always on the last version >. 2.28, since M1 is new hardware, and It can cause trouble in versions for other hardware.
我真的建议你使用相同的设置,因为它可以保留你的python根,也可以避免这些问题。
因此,请尝试以下操作:1-安装pyenv2-安装python 3.10或>版本,使用pyenv。3-安装python venv4-创建虚拟环境,并安装请求5-使用虚拟环境运行您的代码,并检查它是否解决了您的问题。