GithubHelp home page GithubHelp logo

Comments (14)

Stophface avatar Stophface commented on August 29, 2024

Well, I got it installed without pip, through setup.py.
Running it from the terminal you need to specify which version of python you want it install to. In my case

$python3.3 steup.py install

But I cannot import it. thats the errormessage I get!

import langid

thats what I get:

import langid
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/langid-1.1.4dev_r0-py3.3.egg/langid/__init__.py", line 1, in <module>
from langid import classify, rank, set_languages
ImportError: cannot import name classify
>>> 

from langid.py.

Stophface avatar Stophface commented on August 29, 2024

I tried that solution here 7b362ac

But when I try to import it now it gives me the following:

import langid
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/langid-1.1.4dev_r0-py3.3.egg/langid/__init__.py", line 1, in <module>
from .langid import classify, rank, set_languages
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/langid-1.1.4dev_r0-py3.3.egg/langid/langid.py", line 227
raise ValueError, "Unknown language code %s" % lang
                ^
SyntaxError: invalid syntax

from langid.py.

saffsd avatar saffsd commented on August 29, 2024

@Stophface thanks for reporting the issue. The problem is that pip install installs the Python 2 version of langid.py rather than the Python 3 version. I'm not very familiar with Python packaging so I don't actually know how to properly package langid.py for both versions of Python - any help on this topic would be welcome! The only workaround I can offer is that langid.py is a single-file module and there is a version that does work with Python3 here. You can download this to the same location as the rest of your code and from there import langid should work as expected.

from langid.py.

Stophface avatar Stophface commented on August 29, 2024

@saffsd thanks for the reply. I have absolutely no idea how to solve that problem. I just started to learn python. Sorry that I cannot be of any more help.
But I solved the problem with the "python version confusion". I updated my second post. One needs to add the version of python to the installing command.

Regarding your hint: Where do I need to save file you linked exactly and what do I have to name it? Should I save it as a .py file?

from langid.py.

Casyfill avatar Casyfill commented on August 29, 2024

I have same issue using python 2.7:
Could not find a version that satisfies the requirement langid (from versions: 1.0dev, 1.1.1dev, 1.1.2dev, 1.1.3dev, 1.1.4dev, 1.1dev)

from langid.py.

saffsd avatar saffsd commented on August 29, 2024

@Stophface sorry for taking awhile to reply. Yes, you should save it as a .py file. Rather than try and explain Python modules it might be better if I point you to the Python documentation on them [1], it will give you a more complete picture of how Python looks for code when you invoke import xxx. The brief explanation is that the first thing Python looks for when you import langid is a file in the current working directory called langid.py.

@Casyfill that's odd, I'm not able to reproduce that on my end. Could you provide a bit more detail, specifically the command that you are issuing and the associated log files? Thanks!

[1] https://docs.python.org/2/tutorial/modules.html

from langid.py.

Stophface avatar Stophface commented on August 29, 2024

@saffsd It worked. I copied the content of your link and created a langid.py file and replaced the old langid.py file with it. Works like a charme now. Thanks a lot, and very good work. I will use it for my thesis which I will write at the beginning of next year :)

from langid.py.

utilitarianexe avatar utilitarianexe commented on August 29, 2024

pip install --pre langid
should work

from langid.py.

Dnncha avatar Dnncha commented on August 29, 2024

utilitarianexe's pip install --pre langid worked for me.

from langid.py.

nathanleiby avatar nathanleiby commented on August 29, 2024

pip install --pre langid worked for me, or alternatively: pip install langid==1.1.4dev (which fits more nicely in a requirements.txt file)

from langid.py.

Stophface avatar Stophface commented on August 29, 2024

That did not work for me (pip install --pre langid).
It installed it (in the python 3.3 folder surprisingly), but importing came an error message. Something with the __init__.py file is wrong. It could not import it.
So I replaced the langid.py file (youll find it in the site-package folder) with that one
https://raw.githubusercontent.com/saffsd/langid.py/python3/langid/langid.py and had a look at the __init__.py file. There seems to be a dot (.) missing in front of langid�.
So it says from langid import classify, rank, set_languages. I wrote it like that from .langid import classify, rank, set_languages.
Now when I try to import it with import langid in the Python IDLE there are no error messages.

That might be useful for someone who comes across this.

from langid.py.

selahlynch avatar selahlynch commented on August 29, 2024

Had installation issues also...
http://stackoverflow.com/questions/29685627/how-do-i-install-langid-python-library-from-github

Ended up just downloading the zip and installing manually.

from langid.py.

hakanw avatar hakanw commented on August 29, 2024

Is the problem here that the version number on pypi is e.g. "1.1.4dev" while "1.1.4" is specified in the setup.py?

from langid.py.

saffsd avatar saffsd commented on August 29, 2024

Fixing #35 should make pip install langid work as expected now.

from langid.py.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.