Difference between revisions of "Apertium-quality/Installation"

From Apertium
Jump to navigation Jump to search
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Requirements ==
== Requirements ==

You must have:
You must have:
* Python >=3.1
* Python >=3.1
* mwtools. Can be found in https://github.com/apertium/apertium-quality/tree/master/mwtools and installed with:

<pre>
sudo python3 ./setup.py install
</pre>


Recommended for installation:
Recommended for installation:
Line 28: Line 34:


Git:
Git:
<pre>git clone git://github.com/bbqsrc/apertium-quality.git</pre>
<pre>git clone git://github.com/apertium/apertium-quality.git</pre>

SVN:
<pre>svn co https://apertium.svn.sourceforge.net/svnroot/apertium/trunk/apertium-tools/apertium-quality</pre>


Tarball:
Tarball:
<pre>wget https://github.com/bbqsrc/apertium-quality/tarball/master</pre>
<pre>wget https://github.com/apertium/apertium-quality/tarball/master</pre>


=== With root ===
=== With root ===
Line 50: Line 53:


After installation, restart your terminal.
After installation, restart your terminal.

==Troubleshooting==

=== DistributionNotFound (PYTHONPATH not set) ===
<pre>
$ aq-covtest
Traceback (most recent call last):
File "/usr/local/bin/aq-covtest", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 2710, in <module>
working_set.require(__requires__)
File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: apertium-quality==0.3
</pre>

Your PYTHONPATH is most likely not correct (when you did "make install", it told you the path to add to it).

=== bad marshal data ===

If you get the following error on make install:
<pre>
Traceback (most recent call last):
File "setup.py", line 36, in <module>
"""
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 929, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 948, in run_command
cmd_obj.run()
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/install.py", line 73, in run
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/install.py", line 93, in do_egg_install
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 948, in run_command
cmd_obj.run()
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 227, in run
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 266, in zip_safe
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 402, in analyze_egg
File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 429, in scan_module
ValueError: bad marshal data (unknown type code)
</pre>

Then you should do the following:
* make clean
* run make again, but as soon as possible after you see the following, you should ^Z
Extracting in /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmpv32b6a
Now working in /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmpv32b6a/distribute-0.6.19
* you need to hit ^Z before you see this:
copying setuptools/command/bdist_egg.py -> build/src/setuptools/command
* apply the patch below with a command like this:
$ patch -p1 /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmp_ai22w/distribute-0.6.19/setuptools/command/bdist_egg.py < diff
* fg and then do make install as before

Here's the patch that should go in the file "diff" above:
<pre>
--- a/setuptools/command/bdist_egg.py
+++ b/setuptools/command/bdist_egg.py
@@ -425,7 +425,11 @@ def scan_module(egg_dir, base, name, stu
return True # Extension module
pkg = base[len(egg_dir)+1:].replace(os.sep,'.')
module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0]
- f = open(filename,'rb'); f.read(8) # skip magic & date
+ f = open(filename,'rb')
+ if sys.version_info < (3, 3):
+ f.read(8) # skip magic & date
+ else:
+ f.read(12) # skip magic, date & size
code = marshal.load(f); f.close()
safe = True
symbols = dict.fromkeys(iter_symbols(code))
</pre>

See [https://bitbucket.org/tarek/distribute/issue/283] and [https://bitbucket.org/tarek/distribute/pull-request/10/add-tests-and-fix-for-marshalload-of-pyc/diff] regarding this problem.

Latest revision as of 01:44, 23 March 2018

Requirements[edit]

You must have:

sudo python3 ./setup.py install

Recommended for installation:

  • python3-lxml [1]
  • python3-nltk (Available in my repository; explained later)

All other dependencies are installed automatically.

With easy_install[edit]

If you have easy_install installed for Python 3, just run:

easy_install apertium-quality

From source[edit]

The source code can be acquired in a few ways.

Git:

git clone git://github.com/apertium/apertium-quality.git

Tarball:

wget https://github.com/apertium/apertium-quality/tarball/master

With root[edit]

Installing to the root of your Python installation is easy:

./autogen.sh
make && make install && make install-nltk

Enter yes when prompted. If errors are spat about incorrect Python version being detected, tell it which Python 3 to use with the PYTHON environment variable like:

PYTHON=/path/to/python3 ./autogen.sh

Without root (user prefix)[edit]

Installation without root is no more difficult than above:

./autogen.sh --prefix ~/yourprefix
make && make install && make install-nltk

After installation, restart your terminal.

Troubleshooting[edit]

DistributionNotFound (PYTHONPATH not set)[edit]

$ aq-covtest
Traceback (most recent call last):
  File "/usr/local/bin/aq-covtest", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 2710, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 686, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.2/site-packages/distribute-0.6.19-py3.2.egg/pkg_resources.py", line 584, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: apertium-quality==0.3

Your PYTHONPATH is most likely not correct (when you did "make install", it told you the path to add to it).

bad marshal data[edit]

If you get the following error on make install:

Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    """
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 929, in run_commands
    self.run_command(cmd)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 948, in run_command
    cmd_obj.run()
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/install.py", line 73, in run
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/install.py", line 93, in do_egg_install
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/distutils/dist.py", line 948, in run_command
    cmd_obj.run()
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 227, in run
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 266, in zip_safe
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 402, in analyze_egg
  File "/Users/jonathan/apertium/apertium-quality/distribute-0.6.19-py3.3.egg/setuptools/command/bdist_egg.py", line 429, in scan_module
ValueError: bad marshal data (unknown type code)

Then you should do the following:

  • make clean
  • run make again, but as soon as possible after you see the following, you should ^Z
 Extracting in /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmpv32b6a
 Now working in /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmpv32b6a/distribute-0.6.19
  • you need to hit ^Z before you see this:
 copying setuptools/command/bdist_egg.py -> build/src/setuptools/command
  • apply the patch below with a command like this:
 $ patch -p1 /var/folders/bs/7zfncgfd4g11r80fyhbvgtph0000gq/T/tmp_ai22w/distribute-0.6.19/setuptools/command/bdist_egg.py  < diff 
  • fg and then do make install as before

Here's the patch that should go in the file "diff" above:

--- a/setuptools/command/bdist_egg.py
+++ b/setuptools/command/bdist_egg.py
@@ -425,7 +425,11 @@ def scan_module(egg_dir, base, name, stu
         return True     # Extension module
     pkg = base[len(egg_dir)+1:].replace(os.sep,'.')
     module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0]
-    f = open(filename,'rb'); f.read(8)   # skip magic & date
+    f = open(filename,'rb')
+    if sys.version_info < (3, 3):
+        f.read(8)   # skip magic & date
+    else:
+        f.read(12)  # skip magic, date & size
     code = marshal.load(f);  f.close()
     safe = True
     symbols = dict.fromkeys(iter_symbols(code))

See [2] and [3] regarding this problem.