install scikit-learn for python 3.3 on windows 7 - scikit-learn

I am really new to the use of Python and the associated packages that can be installed.
As a biologist I am looking for a lot of new packages that would help me model species systems, ecological change etc.. and after a lot of "Google-ing" I came across scikit-learn.
However, I am having trouble installing it. And I will take this moment now to apologise for the length of this post.
I am using 64bit Python 3.3 and have the associated NumPy (MKL 1.7.0) and SciPy. I installed distribute which worked fine and allows me to use easy_install.
So to install scikit-learn, I tried using the cmd prompt (Windows) run in administrator mode, and then also through Python command line.
I placed the downloaded and extracted tar.gz file in the Lib\site-packages folder.
When I run the command
easy_install scikit-learn
in cmd prompt.
Then this is the following output:
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>
So the little ^ seems to be pointing at the " after RNGS with %r. Which from what I can tell is in the 'init' file from the sklearn folder found in the .tar.gz file.
I also get the same result when running it in the Python GUI and command line.
How can I install scikit-learn with Python 3.3? Is there some way of building it or editing the file to get past this invalid syntax error?
Any help would be greatly appreciated. And I am very sorry for it being such a long post. I was just trying to get all the details in there.
Thanks
Simon

scikit-learn does not support Python 3 yet. For now you need Python 2.7.
Proper support for Python 3 is expected for the 0.14 release scheduled for Q2-2013.

I am no expert, but in my understanding the print statement in Python 3.* is now a function, called like: print(). So, a quick solution in this case is to change
print "I: Seeding RNGs with %r" % _random_seed
to
print("I: Seeding RNGs with %r" % _random_seed)

Related

problems installing sqlite and python on freebsd

This is driving me crazy! Any help you can provide will be most welcome!
I have a python3/sqlite application (running in a virtual environment) that is working fine on debian. I need to install it on freebsd (running in a virtual environment). I have installed python3 and sqlite (I can open a .sqlite file from the command line).
When I try to run the python script, I get the following error:
(venv) [jordan#webServer ~/crons/powerwall]$ python3 main.py
Traceback (most recent call last):
File "/usr/home/jordan/crons/powerwall/main.py", line 78, in <module>
run()
File "/usr/home/jordan/crons/powerwall/main.py", line 33, in run
database.load_db(config_mgr=config)
File "/usr/home/jordan/crons/powerwall/database.py", line 108, in load_db
db = PowerWallDb(cfg_mgr=config_mgr)
File "/usr/home/jordan/crons/powerwall/database.py", line 94, in __init__
super().__init__(cfg_mgr=cfg_mgr, section=section)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 77, in __init__
self._connect_sqlite(self.sqlite_file, check_same_thread=False)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 99, in _connect_sqlite
self._connect_uri(uri, **kwargs)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/thompcoutils/db_utils.py", line 95, in _connect_uri
self.connection = sqlobject.sqlhub.processConnection = sqlobject.connectionForURI(uri, **kwargs)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 1105, in connectionForURI
conn = connCls.connectionFromURI(uri)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 154, in connectionFromURI
return cls._connectionFromParams(*cls._parseURI(uri))
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 122, in _connectionFromParams
return cls(filename=path, **args)
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 64, in __init__
raise ImportError(
ImportError: Cannot find an SQLite driver, tried supersqlite,pysqlite2,sqlite3,sqlite
Exception ignored in: <function DBAPI.__del__ at 0x8029c1310>
Traceback (most recent call last):
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/dbconnection.py", line 704, in __del__
self.close()
File "/usr/home/jordan/crons/powerwall/venv/lib/python3.9/site-packages/sqlobject/sqlite/sqliteconnection.py", line 217, in close
if self._memory:
AttributeError: 'SQLiteConnection' object has no attribute '_memory'
You have to install py-sqlite3 which is the "Standard Python binding to the SQLite3 library"
Install From Ports:
cd /usr/ports/databases/py-sqlite3/ && make install clean
Install From pkg:
pkg install databases/py-sqlite3
Basically, it looks like the standard Python bindings for SQLite is a separate package on FreeBSD (perhaps, on all *nix/*BSD). So, in general, there are three components, which you need, Python, SQLite (this one may not be actually necessary for Python) AND the standard Python bindings for SQLite. I have not worked with FreeBSD, but based on Googling, have you tried installing this https://pkgs.org/download/py39-sqlite3 maybe?

Tensorflow breaks pip on anaconda, windows os

Last version of anaconda, windows 10, python 3.6.
Installing tensorflow seems to break pip.
>conda create -n py6 python=3.6
>activate py6
>conda install tensorflow
>pip install tweepy
Collecting tweepy
Exception:
Traceback (most recent call last):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_set.py", line 554, in _prepare_file
require_hashes
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\req\req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "C:\Programs\Anaconda3\envs\py6\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Use of tweepy is just an example, pip cannot install any package.
The same happens when installing tensorflow using pip, and when using a python 3.5 virtual environment.
Probably this is due to some package update gone wrong, and it will be fixed in the next update.
Meanwhile, any fix or any careful selection of working version numbers is welcome.
This issues is reported in the following ticket : https://github.com/tensorflow/tensorboard/issues/588
To solve this, you need to repair html5lib.
Or alternatively,
you can make use of anaconda to re-install
conda install -c anaconda html5lib

py2app Mach-O header error

I am trying to use py2app on the following code:
print(1+1)
I create my setup with:
py2applet --make-setup test.py
Development with alias mode works fine:
python3 setup.py py2app -A
But when I try the standalone mode:
python3 setup.py py2app
I get after a lot of lines:
WARNING: Mach-O header in '/Users/quentinpeter/Documents/PHD/Python/People project/Michele_worms/dist/test.app/Contents/Resources/lib/python3.6/scipy/linalg/_interpolative.cpython-36m-darwin.so' may be too large to relocate
WARNING: Mach-O header in '/Users/quentinpeter/Documents/PHD/Python/People project/Michele_worms/dist/test.app/Contents/Resources/lib/python3.6/scipy/linalg/_interpolative.cpython-36m-darwin.so' may be too large to relocate
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/site-packages/py2app/build_app.py", line 764, in run
self._run()
File "/usr/local/lib/python3.6/site-packages/py2app/build_app.py", line 974, in _run
self.run_normal()
File "/usr/local/lib/python3.6/site-packages/py2app/build_app.py", line 1082, in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/usr/local/lib/python3.6/site-packages/py2app/build_app.py", line 1385, in create_binaries
platfiles = mm.run()
File "/usr/local/lib/python3.6/site-packages/macholib/MachOStandalone.py", line 146, in run
node.write(f)
File "/usr/local/lib/python3.6/site-packages/macholib/MachO.py", line 133, in write
header.write(f)
File "/usr/local/lib/python3.6/site-packages/macholib/MachO.py", line 343, in write
self.synchronize_size()
File "/usr/local/lib/python3.6/site-packages/macholib/MachO.py", line 333, in synchronize_size
self.parent.filename, self.total_size + self.sizediff, self.low_offset, self.sizediff))
ValueError: New Mach-O header is too large to relocate in '/Users/quentinpeter/Documents/PHD/Python/People project/Michele_worms/dist/test.app/Contents/Resources/lib/python3.6/scipy/linalg/_interpolative.cpython-36m-darwin.so' (new size=1764, max size=1712, delta=108)
Do you have any idea what might happen? Most of the things I found online refers to MacPorts but I use homebrew.
info on my python:
Python 3.6.0 (default, Dec 24 2016, 08:01:42)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
I had the same problem and I fixed it by uninstalling the version of macholib that I had (1.8) and installing 1.7 with pip. When using python 2.7, reverting to scipy version 0.14.0 would fix it as well.

Pyramid install under Python 3.3 gives pkg_resources.DistributionNotFound: <myproject> under Windows

I have freshly installed Python 3.3 (x64) and PyWin32, and then did the following (mindeningyen-env is the directory of the virtualenv, mindeningyen is the name of the app):
distribute_setup.py
easy_install virtualenv
virtualenv --no-site-packages mindeningyen-env
cd mindeningyen-env
Scripts\activate
easy_install pyramid
pcreate -s alchemy mindeningyen
cd mindeningyen
setup.py develop
pip install waitress
And then I get the following trace:
(mindeningyen-env) D:\prg\mindeningyen-env\mindeningyen>pserve development.ini
Traceback (most recent call last):
File "d:\prg\mindeningyen-env\Scripts\pserve-script.py", line 9, in <module>
load_entry_point('pyramid==1.4', 'console_scripts', 'pserve')()
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 50, in main
return command.run()
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 304, in run
global_conf=vars)
File "d:\prg\mindeningyen-env\lib\site-packages\pyramid-1.4-py3.3.egg\pyramid\scripts\pserve.py", line 328, in loadapp
return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 271, in loadobj
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 320, in _loadconfig
return loader.get_context(object_type, name, global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 454, in get_context
section)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 476, in _context_from_use
object_type, name=use, global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 406, in get_context
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 296, in loadcontext
global_conf=global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 328, in _loadegg
return loader.get_context(object_type, name, global_conf)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 620, in get_context
object_type, name=name)
File "d:\prg\mindeningyen-env\lib\site-packages\pastedeploy-1.5.0-py3.3.egg\paste\deploy\loadwsgi.py", line 640, in find_egg_entry_point
pkg_resources.require(self.spec)
File "d:\prg\mindeningyen-env\lib\site-packages\distribute-0.6.31-py3.3.egg\pkg_resources.py", line 706, in require
needed = self.resolve(parse_requirements(requirements))
File "d:\prg\mindeningyen-env\lib\site-packages\distribute-0.6.31-py3.3.egg\pkg_resources.py", line 604, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: mindeningyen
Any ideas why it doesn't find the project?
Using the new Python 3.3 native virtual env implementation, I can use Pyramid on Python 3.3 just fine:
python3.3 -m venv mindeningyen-env
cd mindeningyen-env/
source bin/activate
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
bin/easy_install pyramid
bin/pcreate -s alchemy mindeningyen
cd mindeningyen
python setup.py develop
cd ..
bin/pserve mindeningyen/development.ini
If using virtualenv (either installed, or python builtin), one shouldn't say things like
setup.py develop, because that will use the python interpreter, which is found in registry. One should ensure the virtualenv is activated Scripts\activate, and after that every python run should use python, so, the correct form is:
python setup.py develop

how can i fix this invalid ELF header errror?

I installed zeromq on ubuntu 10.04 and the compilation went through without any errors.
However when i try to run the python test, it results in this error:
jerome#VM1:~/zeromq/pyzmq-2.0.7$ python setup.py test
running test
Traceback (most recent call last):
File "setup.py", line 144, in <module>
'Topic :: System :: Networking'
File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
cmd_obj.run()
File "setup.py", line 59, in run
tests = TestLoader().loadTestsFromNames(testfiles)
File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/home/jerome/zeromq/pyzmq-2.0.7/zmq/__init__.py", line 26, in <module>
from zmq import _zmq
ImportError: /home/jerome/zeromq/pyzmq-2.0.7/zmq/_zmq.so: invalid ELF header
What do i need to do to fix this?
Try setting up pyzmq like this:
python setup.py configure --zmq=<your_zmqlibrary_installation_path>
python setup.py build_ext --rpath=<your_zmqlibrary_installation_path>/lib --inplace
python setup.py install
python setup.py test
According to how can i fix this invalid ELF header errror? you need to compile zeromq on your target instead of using a MAC OS X version ...

Resources