【问题标题】:switching between python 2.7 and 3.5 on mac OSX 10.7.4?在 mac OSX 10.7.4 上的 python 2.7 和 3.5 之间切换?
【发布时间】:2017-03-13 05:04:10
【问题描述】:

我的 Mac OSX 10.7.4 上同时安装了 python 2.7 和 3.5。 我用 3.5 编写的 python 脚本使用以下命令可以正常工作:

python3 <file.py>

但是,运行另一个与 python 2.7 兼容的脚本会给我这个错误:

python testfile.py
Traceback (most recent call last):
  File "testfile.py", line 29, in <module>
    br.select_form(name="signinWidget")
  File "build/bdist.macosx-10.7-intel/egg/mechanize/_mechanize.py", line 524, in select_form
mechanize._mechanize.FormNotFoundError: no form matching name 'signinWidget'

脚本使用 mechanize 和 BeautifulSoup 包。

>which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

我试过了:

python -m pip install BeautifulSoup,mechanize

但它不能解决这个问题。

如何确保脚本指向已安装在我的 mac 上的正确软件包?

【问题讨论】:

    标签: macos python-2.7 python-3.5


    【解决方案1】:

    你应该尝试 pip3 来安装 python3 的模块

    pip3 install BeautifulSop4 
    

    【讨论】:

    • 我的问题是运行 python 2.7 时无法识别包。 >python -m pip install BeautifulSoup,mechanize 已经满足要求(使用--upgrade升级): /Library/Python/2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg 中的BeautifulSoup 你使用的是pip版本8.0.2,但版本 8.1.2 可用。您应该考虑通过“pip install --upgrade pip”命令进行升级。 Pip 升级也没有削减它。
    • 文件“build/bdist.macosx-10.7-intel/egg/mechanize/_mechanize.py”,第 524 行,在 select_form mechanize._mechanize.FormNotFoundError: no form matching name 'signinWidget'
    • no form matching name 'signinWidget' ,是在表格的形式中没有找到名字,不是包不被识别的问题
    • 您应该确认表格的名称。这个也有类似的问题,link
    • 非常感谢您为我指明了正确的方向。该脚本正在尝试访问“seller central.amazon.in”上的登录信息。我使用“检查元素”验证了小部件,表单名称为“signinWidget”。这以前可以工作,但几个月后就停止了。再次道歉,如果我遗漏了任何明显的东西。
    猜你喜欢
    • 2016-04-13
    • 2016-10-08
    • 2017-06-10
    • 2017-12-17
    • 2018-12-24
    • 2016-06-14
    • 2019-04-19
    • 1970-01-01
    • 2012-05-13
    相关资源
    最近更新 更多