2

我对 Python 的使用和可以安装的相关软件包非常陌生。作为一名生物学家,我正在寻找许多可以帮助我模拟物种系统、生态变化等的新软件包。经过大量“谷歌搜索”后,我遇到了 scikit-learn。但是,我无法安装它。我现在要为这篇文章的篇幅道歉。

我正在使用 64 位 Python 3.3 并具有相关的 NumPy (MKL 1.7.0) 和 SciPy。我安装了运行良好的分发版,并允许我使用easy_install。所以要安装 scikit-learn,我尝试使用 cmd 提示符(Windows)以管理员模式运行,然后也通过 Python 命令行。我将下载并提取的 tar.gz 文件放在 Lib\site-packages 文件夹中。当我 easy_install scikit-learn 在 cmd 提示符下运行命令时。然后这是以下输出:

C:\Python33\Lib\site-packages>easy_install -U scikit-learn
Searching for scikit-learn
Reading http://pypi.python.org/simple/scikit-learn/
Reading http://scikit-learn.org
Reading http://sourceforge.net/projects/scikit-learn/files/
Reading http://scikit-learn.sourceforge.net
Best match: scikit-learn 0.12.1
Downloading http://pypi.python.org/packages/source/s/scikit-learn/scikit-learn-0
.12.1.tar.gz#md5=7e8b3434f9e8198b82dc3774f8bc9394
Processing scikit-learn-0.12.1.tar.gz
Writing c:\users\nuvraj~1\appdata\local\temp\easy_install-kvr2q0\scikit-learn-0.
12.1\setup.cfg
Running scikit-learn-0.12.1\setup.py -q bdist_egg --dist-dir c:\users\nuvraj~1\a
ppdata\local\temp\easy_install-kvr2q0\scikit-learn-0.12.1\egg-dist-tmp-l618ie
Traceback (most recent call last):
  File "C:\Python33\Scripts\easy_install-script.py", line 9, in <module>
    load_entry_point('distribute==0.6.33', 'console_scripts', 'easy_install')()
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
1937, in main
    with_ei_usage(lambda:
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
1918, in with_ei_usage
    return f()
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
1941, in <lambda>
    distclass=DistributionWithoutHelpCommands, **kw
  File "C:\Python33\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python33\lib\distutils\dist.py", line 917, in run_commands
    self.run_command(cmd)
  File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
    cmd_obj.run()
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
358, in run
    self.easy_install(spec, not self.no_deps)
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
598, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
628, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
823, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
1103, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "C:\Python33\lib\site-packages\setuptools\command\easy_install.py", line
1089, in run_setup
    run_setup(setup_script, args)
  File "C:\Python33\lib\site-packages\setuptools\sandbox.py", line 34, in run_se
tup
    lambda: exec(compile(open(
  File "C:\Python33\lib\site-packages\setuptools\sandbox.py", line 82, in run
    return func()
  File "C:\Python33\lib\site-packages\setuptools\sandbox.py", line 37, in <lambd
a>
    {'__file__':setup_script, '__name__':'__main__'})
  File "setup.py", line 33, in <module>
  File "c:\users\nuvraj~1\appdata\local\temp\easy_install-kvr2q0\scikit-learn-0.
12.1\sklearn\__init__.py", line 86
    print "I: Seeding RNGs with %r" % _random_seed
                                  ^
SyntaxError: invalid syntax

C:\Python33\Lib\site-packages>

因此,小 ^ 似乎指向带有 %r 的 RNGS 之后的“。据我所知,这在 .tar.gz 文件中的 sklearn 文件夹中的“ init ”文件中。

在 Python GUI 和命令行中运行它时,我也得到了相同的结果。

如何使用 Python 3.3 安装 scikit-learn?是否有某种方法可以构建它或编辑文件以克服这个无效的语法错误?

任何帮助将不胜感激。我很抱歉这篇文章这么长。我只是想把所有的细节都放进去。

谢谢西蒙

4

2 回答 2

2

scikit-learn 还不支持 Python 3。现在你需要 Python 2.7。

预计将于 2013 年第二季度发布的 0.14 版本对 Python 3 提供适当支持。

于 2013-01-08T09:39:47.583 回答
0

我不是专家,但据我了解,Python 3.* 中的 print 语句现在是一个函数,称为 print()。因此,在这种情况下,一个快速的解决方案是更改

print "I: Seeding RNGs with %r" % _random_seed

print("I: Seeding RNGs with %r" % _random_seed)
于 2013-06-17T18:40:34.820 回答