I am trying to tokenize text. For it to work, I was trying Polygot and installed the way, has been mentioned in the documentation. After installing it, I have been trying to make the simple script run:
import polyglot
from polyglot.text import Text, Word
text = Text("\"သမၼတဦးဝင္းျမင့္ရဲ႕ ျခင္းခတ္ကစားဟန္\"\n\nႏိုင္ငံေတာ္သမၼတ ဦးဝင္းျမင့္ ျမန္မာ့ရိုးရာဝိုင္းျခင္းခတ္ ေနတဲ့ပုံေတြ ဟာ ဒီကေန႕ ညေနပိုင္းမွာထြက္ရိွလာပါတယ္။\n\nဒီကေန႕ ညေနပိုင္းမွာ သမၼတအိမ္ေတာ္ဝင္းအတြင္းမွာ သမၼတဟာ သူရဲ႕မိတ္ေဆြေတြနဲ႕ ျခင္းခတ္ခဲ့တာလို႕ သိရပါတယ္။\n\nသမၼတနဲ႕ဝိုင္းျခင္းခတ္တဲ့သူေတြထဲမွာေတာ့ အမ်ိဳးသားလႊတ္ေတာ္ကိုယ္စားလွယ္ ဦးေက်ာ္သီဟ ၊ အစိုးရ ရဲ႕ၿငိမ္းခ်မး္ေရးေကာ္မရွင္အဖြဲ႕ဝင္ ဦးေအာင္စိုးတို႕ပါဝင္ၾကပါတယ္။\n\nသမၼတ ဦးဝင္းျမင့္ဟာ သမၼတတာဝန္မထမ္းေဆာင္မီ လႊတ္ေတာ္ကိုယ္စားလွယ္အျဖစ္ ေနျပည္ေတာ္က စည္ပင္ဧည္႕ရိပ္သာဝင္းအတြင္း ေနထိုင္စဥ္ကတည္းက အမ်ိဳးသားဒီမိုကေရစီအဖြဲ႕ခ်ဳပ္ ပါတီဝင္လႊတ္ေတာ္ကိုယ္စားလွယ္အခ်ိဳ႕နဲ႕ ညေနပိုင္းေတြမွာ ျခင္းခတ္ေလ့ရိွပါတယ္။\n\nကိုယ္လက္လႈပ္ရွားအားကစားအျဖစ္ ျခင္းခတ္ေလ့ရိွတဲ့သူေတြထဲမွာ ေတာ့ လက္ရိွ မႏၱေလးတိုင္းဝန္ႀကီးခ်ဳပ္ ေဒါက္တာေဇာ္ျမင့္ေမာင္ ၊ ဧရာဝတီတိုင္းဝန္ႀကီးခ်ဳပ္ေဟာင္း မန္းေဂ်ာ္နီတို႕လည္း ပါဝင္ေလ့ရိွပါတယ္။ ")
print(text.words)
but have been getting an error saying:
Traceback (most recent call last):
File "tkn.py", line 2, in <module>
from polyglot.text import Text, Word
File "/home/ubuntu/anaconda3/envs/python3/lib/python3.6/site-packages/polyglot/text.py", line 9, in <module>
from polyglot.detect import Detector, Language
File "/home/ubuntu/anaconda3/envs/python3/lib/python3.6/site-packages/polyglot/detect/__init__.py", line 1, in <module>
from .base import Detector, Language
File "/home/ubuntu/anaconda3/envs/python3/lib/python3.6/site-packages/polyglot/detect/base.py", line 11, in <module>
from icu import Locale
ModuleNotFoundError: No module named 'icu'
To resolve this, I tried multiple steps mentioned here and few answers as given here but it has not solved the problem. I am working with Ubuntu.
Also, if I try to install pip install pyicu as some of the posts suggest, I get an error while trying to install it saying Failed building wheel for pyicu and error: command 'gcc' failed with exit status 1.
I am not sure how to proceed from here. How could I resolve the related error and make the script work?
I also downloaded and installed icu (building it manually for Ubuntu)but no help.
curl -LO http://download.icu-project.org/files/icu4c/63.1/icu4c-63_1-src.tgz
tar xzvf icu4c-63_1-src.tgz
cd icu/source
chmod +x runConfigureICU configure install-sh
./runConfigureICU Linux
make
sudo make install
sudo cp -r common/unicode /usr/local/include/
Related
I have a pyproject.toml file that was created using poetry, and I'm trying to run the command poetry install in this directory to create a poetry.lock file. However, when I run poetry install, I get the following error:
EnvCommandError
Command C:\Users\myName\AppData\Local\pypoetry\Cache\virtualenvs\my-app-name-kS94etse-py3.8\Scripts\python.exe -
errored with the following return code 3, and output:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "c:\users\myName\anaconda3\lib\io.py", line 52, in <module>
File "c:\users\myName\anaconda3\lib\abc.py", line 106
print(f"Class: {cls.__module__}.{cls.__qualname__}", file=file)
^
SyntaxError: invalid syntax
input was : import sys
This error seems pretty in depth but I dont understand why poetry thinks import sys is invalid syntax or even where that's being called to create an issue. Any suggestions on how to fix this?
Resolved here:
https://stackoverflow.com/a/67169273/12060361
Download a new, non-broken version of Python (the same version defined in your pyproject.toml file to use): https://www.python.org/downloads/release/python-385/
Navigate to the virtual env folder poetry says the error is coming from: C:\Users\myName\AppData\Local\pypoetry\Cache\virtualenvs\my-app-name-kS94etse-py3.8\Scripts\python.exe
Replace the python.exe currently in that folder with the new one you just downloaded
I recently upgraded from Python3.6 to Python3.7. Since I have upgraded, when I type in ipython3 in the terminal I get an error:
~$ ipython3
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3/dist-packages/IPython/__init__.py", line 48, in <module>
from .core.application import Application
File "/usr/lib/python3/dist-packages/IPython/core/application.py", line 25, in <module>
from IPython.core import release, crashhandler
File "/usr/lib/python3/dist-packages/IPython/core/crashhandler.py", line 28, in <module>
from IPython.core import ultratb
File "/usr/lib/python3/dist-packages/IPython/core/ultratb.py", line 124, in <module>
from IPython.utils import path as util_path
File "/usr/lib/python3/dist-packages/IPython/utils/path.py", line 18, in <module>
from IPython.utils.process import system
File "/usr/lib/python3/dist-packages/IPython/utils/process.py", line 19, in <module>
from ._process_posix import system, getoutput, arg_split, check_pid
File "/usr/lib/python3/dist-packages/IPython/utils/_process_posix.py", line 24, in <module>
import pexpect
File "/usr/lib/python3/dist-packages/pexpect/__init__.py", line 75, in <module>
from .pty_spawn import spawn, spawnu
File "/usr/lib/python3/dist-packages/pexpect/pty_spawn.py", line 14, in <module>
from .spawnbase import SpawnBase
File "/usr/lib/python3/dist-packages/pexpect/spawnbase.py", line 224
def expect(self, pattern, timeout=-1, searchwindowsize=-1, async=False):
^
SyntaxError: invalid syntax
Furthermore I have noticed that my jupyter-notebook does not seem to work with the python3 kernel now as well (I get the kernel dead error).
NOTEs:
ipython and jupyter-notebook are working with fine when I use them with Python2.
I am using Ubuntu 18.04 (Bionic Beaver) although I don't think this is relevant
async is a reserved keyword in python3.7 and an old version of pexpect is using async as variable. The solution is to upgrade pexpect.
For me, it was conflicting with apt-get installed python3, so I had to first uninstall it/them:
sudo apt-get remove python-pexpect python3-pexpect
And then
sudo pip3.7 install --upgrade pexpect
UPDATE Please update your installed packages.
This error for pexpect has been reported and closed already issue
In Python 3.7, async and await are now reserved keywords. This is what is breaking some of your installed packages.
If you do not need the new features in 3.7, roll back to 3.6 and wait until your packages are updated to support the new syntax in 3.7
What's New in Python 3.7
I just solve this problem by upgrading pexpect manually.
Download pexpect4.6 source code from https://github.com/pexpect/pexpect/releases/tag/4.6
Extract the source code, get into the folder and install the pexpect by:
sudo python3.7 setup.py install
As others have noted, having the current version of the pexpect package should solve this. In my case, the python3-pexpect package that I had installed through apt was stuck on an old version and I first had to remove it. Then installing the current pexpect package through pip3 fixed the problem.
This appears to be an issue related to async being keyword in Python 3.7
As given here, updating pipenv might be the solution
async is a reserved word in Python 3.7
You can edit the packages yourself if you feel comfortable doing it.
Here is a shell command that does just that:
sed "s/async/_async/g" "/usr/lib/python3/dist-packages/pexpect/spawnbase.py" > tmp.txt && cat tmp.txt > "/usr/lib/python3/dist-packages/pexpect/spawnbase.py" && rm tmp.txt
Otherwise, you might want to use Python 3.6 while waiting for an update.
I have been using WinPython 2.2.5 with Python 2.7 and it works nice. The problem that I have is when I want to install additional libraries to use from the https://pypi.python.org repository.
For example I tried to install pdfminer which is in following link: https://pypi.python.org/pypi/pdfminer/
I have read that I can use pip install which is in the following path on my computer:
C:\WinPython-32bit-2.7.6.3\python-2.7.6\Scripts
On that directory I have saved the tar.gz file of pdfminer and from the windows command prompt on the aforementioned path I have typed:
pip install pdfminer(version number).tar.gz
It seems that it works fine, because there are no error messages, but when I open the winpython and in the command shell I put:
pdf2txt
to see if it works I got the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'pdf2txt' is not defined
What am I doing wrong?
According to the documentation, "PDFMiner comes with two handy tools: pdf2txt.py and dumppdf.py." So, instead of trying to run pdf2txt.py by importing it, you need to run it as it shows in the example in the documentation, like this:
$ pdf2txt.py -o output.html samples/naacl06-shinyama.pdf
where output.html is the file that is created from the mined text, and samples/naac106-shinyama.pdf is the PDF you want to mine.
I am attempting to install this https://github.com/jordens/pyflycapture2 python binding on my Windows machine. The readme only has instructions on how to do it for Linux systems, but I imagine the library should still work.
I am able to run "python setup.py install" and it seems to successfully complete, but when I try to run "python test_flycapture2.py" I get this error:
C:\Users\clinic\Desktop\pyflycapture2>python test_flycapture2.py Traceback (most recent call last):
File "test_flycapture2.py", line 20, in <module>
import flycapture2 as fc2
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
This seems to imply that flycapture2 wasn't installed correctly. When I instead just open a python session and do "import flycapture2" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
Have I done something wrong with the installation process or does pyflycapture2 just not work with Windows?
A dumb solution that's worth a try. There are chances that the DLL are searched directly from where you're starting the python script. So if you have the dll somewhere on your computer, copy it along where you have your test_flycapture2.py.
But given the fact that the setup.py file has a whole bunch of absolute paths in there, I would not place my hopes too high. You can also try to install FlyCapture 2 at the exact same path, run python setup.py bdist_wheel (you will need to install wheel first with pip) in the pyflycapture2 folder, and see if that succeeds.
If it does, try installing the generated wheel (that will be in dist/ subfolder) by doing pip install dist/pyfly....wheel and test again.
Hope this helps
I'm answering this mostly because I found another post where the same question had been posted but the original problem was never answered.
How do I run an installed Python module on Windows?
In the comments, the original poster says that it suddenly started working. I found that the solution was simply to restart my computer. I have now attempted this on two computers and this worked for both of them.
I am trying to install imgseek- the server version (http://www.imgseek.net/) to do image analysis.I am able to install all the dependencies successfully using:
sudo port install swig
sudo port install swig-python
sudo easy_install twisted
sudo port install imagemagick
sudo easy_install epydoc
Then I download isk-daemon from the downloads(isk-daemon-0.9.3.tar.gz) and build and install it. Everything runs succesfully.
But when I run iskdaemon.py from the command prompt, i get the following error:
sk-daemon : WARNING | no config file (isk-daemon.conf) found. Looked at local dir, home user dir and /etc/iskdaemon. Using defaults for everything.
root : ERROR Unable to load the C++ extension "_imgdb.so(pyd)" module.
root : ERROR See http://www.imgseek.net/isk-daemon/documents-1/compiling
Traceback (most recent call last):
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/ImageDB.py", line 35, in
import imgdb
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 28, in
_imgdb = swig_import_helper()
File "/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/imgSeekLib/imgdb.py", line 20, in swig_import_helper
import _imgdb
ImportError: dlopen(/Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so, 2): Symbol not found: __ZNSs4_Rep20_S_empty_rep_storageE
Referenced from: /Users/gghanakota/anaconda/lib/python2.7/site-packages/isk_daemon-0.9.3-py2.7-macosx-10.5-x86_64.egg/_imgdb.so
Expected in: dynamic lookup
Please help!
I had the same problem when I was trying to install iskdaemon on my Mac (osx yosemite).
The problem in my case was that when I was building it, the c++ compiler threw two errors on using min function in imgdb.cpp
The error was because the types of the variables in the min function were not the same. Consequently the build failed and the imgdb module wasn't produced.
I fixed it by adding a simple typecast to the variables passed to the min function:
I changed: min(sz, numres) to min(sz, (long int)numres) on line 1003,
and min((V.size()/2), numres) to min((int)(V.size()/2), numres) on line 1327
I built again and it is working now.
Check if you get any errors when you build, maybe you are facing the same issue.