且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用pip安装Python模块

更新时间:2023-11-04 20:35:16

您使用的是Homebrew或MacPorts吗?正如@JFSebastian所说,听起来你在混合OS X附带的默认python和通过包管理器安装的问题时会出现问题...尝试 / usr / local / opt / python /bin/python2.7 -m scrapy 并查看是否抛出 ImportError

Are you using Homebrew or MacPorts or something? As @J.F.Sebastian said, it sounds like you are having issues mixing the default python that comes with OS X, and one that is installed via a package manager... Try /usr/local/opt/python/bin/python2.7 -m scrapy and see if that throws an ImportError.

如果可行,那么您可能需要考虑将那个 python可执行文件作为默认值。类似别名python2.7 = / usr / local / opt / python / bin / python2.7 然后总是使用 python2.7 而不是默认的 python 。你也可以将 python 指向 / urs / local ... 位,但是你不会有如果您出于某种原因需要它,可以轻松访问系统(OS X提供的)python。

If that works, then you may want to consider making that python executable your default. Something like alias python2.7=/usr/local/opt/python/bin/python2.7 and then always use python2.7 instead of the default python. You can likewise just point python to the /urs/local... bit, but then you won't have easy access to the system (OS X-supplied) python if you ever needed it for some reason.