mpcabd / python-arabic-reshaper

Reconstruct Arabic sentences to be used in applications that don't support Arabic
MIT License
398 stars 80 forks source link

Not working with Python 2.7 #11

Closed abdelhameedhamdy closed 7 years ago

abdelhameedhamdy commented 7 years ago

Salamu Alikom Abdullah,

When trying using the library with Pytohn 2.7 I got the following errors:

File "arabic_reshaper.py", line 26, in from builtins import range ImportError: No module named builtins

Fixed, After changing the following line from builtins import range - To :> from (double-underscore)builtin(double-underscore) import range

Then, got the following error: from configparser import ConfigParser ImportError: No module named configparser

Again, changes the it to : import ConfigParser ,only

Error in ConfigParser () line, then changes to ConfigParser.ConfigParser(), Got other errors !! Knowing that when trying to run it using Python 3, it works with no problem,

mpcabd commented 7 years ago

Please check your installation, it is most probably an incorrect one.

# mpcabd ~ [12:47:03]
$ virtualenv -p python2 py2
Running virtualenv with interpreter /usr/local/bin/python2
New python executable in /Users/mpcabd/py2/bin/python2.7
Also creating executable in /Users/mpcabd/py2/bin/python
Installing setuptools, pip, wheel...done.

# mpcabd ~ [12:47:19]
$ cd py2

# mpcabd ~/py2 [12:47:21]
$ source bin/activate

(py2)
# mpcabd ~/py2 [12:47:25]
$ pip install arabic-reshaper
Collecting arabic-reshaper
  Downloading arabic_reshaper-2.0.1-py2-none-any.whl
Collecting configparser (from arabic-reshaper)
  Downloading configparser-3.5.0.tar.gz
Collecting future (from arabic-reshaper)
  Downloading future-0.16.0.tar.gz (824kB)
    100% |████████████████████████████████| 829kB 1.1MB/s
Building wheels for collected packages: configparser, future
  Running setup.py bdist_wheel for configparser ... done
  Stored in directory: /Users/mpcabd/Library/Caches/pip/wheels/1c/bd/b4/277af3f6c40645661b4cd1c21df26aca0f2e1e9714a1d4cda8
  Running setup.py bdist_wheel for future ... done
  Stored in directory: /Users/mpcabd/Library/Caches/pip/wheels/c2/50/7c/0d83b4baac4f63ff7a765bd16390d2ab43c93587fac9d6017a
Successfully built configparser future
Installing collected packages: configparser, future, arabic-reshaper
Successfully installed arabic-reshaper-2.0.1 configparser-3.5.0 future-0.16.0

(py2)
# mpcabd ~/py2 [12:47:39]
$ python
Python 2.7.13 (default, Dec 17 2016, 23:03:43)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import arabic_reshaper
>>> arabic_reshaper.reshape(u'مرحبا')
u'\ufee3\ufeae\ufea3\ufe92\ufe8e'
>>>

(py2)
# mpcabd ~/py2 [12:48:10]
$

You can install the package either by executing pip install --upgrade arabic-reshaper or by executing pip install --upgrade git+https://github.com/mpcabd/python-arabic-reshaper

abdelhameedhamdy commented 7 years ago

Thanks Abdullah,

Is "python setup.py install" works as well !! as my machine is behind proxy, and I tried to config the console with our enterprise proxy but with no success.

I tried with pip install in mac machine it works properly.

mpcabd commented 7 years ago

python setup.py install should work if you have the dependencies installed.

But if you're on a Linux based machine (Mac or Linux) and you're behind a proxy try to call pip like this maybe it'd work:

http_proxy=<host>:<port> https_proxy=<host>:<port> pip install --upgrade arabic-reshaper

Where you replace <host> and <port> by your enterprise proxy host and port respectively.

For Windows I'm not really sure how proxies work with pip there.