Pycharm: why I can't import cabocha library - python-3.x

My os is Mac OS, and I have install successfully conda, and cabocha.
and I can import cabocha.analyze (which is a Yet Another Japanese Dependency Structure Analyzer - GitHub Pages ) successfully in terminal.
(wmm_env) A1706-084:wmm_env k.den$ python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from cabocha.analyzer import CaboChaAnalyzer
>>>
But in the pycharm, there is error:
from cabocha.analyzer import CaboChaAnalyzer
ModuleNotFoundError: No module named 'cabocha'

Related

How to load a module in Python 3 when there is a package with the same name?

When working on some legacy Python package, I noticed there was a sub-package shadowing a module with the same name. Here is a simplified file hierarchy showing the problem:
t/
t/__init__.py
t/u/
t/u.py
t/u/__init__.py
As you can see, there is a python module t/u.py and also a sub-package t/u/ It looks like a standard import statement loads the sub-package:
$ python3
Python 3.5.2 (default, Oct 8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import t.u
__init__.py
>>>
But, is there a way to import the module t/u.py instead?
Maybe from t import u and from t.u import u works

How can I use SQLite3 v3.7 API on Ubuntu?

I want to backup a sqlite3 database existing_db.db into an in-memory database :memory: using sqlite3.Connection.backup()? backup() is available with SQLite 3.6.11 or higher. New in version 3.7. If I run the follwing code
import sqlite3
source = sqlite3.connect('existing_db.db')
dest = sqlite3.connect(':memory:')
source.backup(dest)
I get the error AttributeError: 'sqlite3.Connection' object has no attribute 'backup'. How can I make backup() work? My setup is Ubuntu 18.04.
$ python3
Python 3.6.6 (default, Sep 12 2018, 18:26:19)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
>>> sqlite3.version
'2.6.0'
>>> sqlite3.sqlite_version
'3.22.0'

Unable to import Pandas in IPython 6.5.0 console (Spyder)

After installing pandas am able to import in cmd as below :
C:\Users\me\Desktop\Django_Project>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
But when am importing pandas in Spyder in IPython 6.5.0 console I get below error:
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.
IPython 6.5.0 -- An enhanced Interactive Python.
c:\program files (x86)\python37-32\lib\site-packages\ipykernel\parentpoller.py:116: UserWarning: Parent poll failed. If the frontend dies,
the kernel may be left running. Please let us know
about your system (bitness, Python, etc.) at
ipython-dev#scipy.org
ipython-dev#scipy.org""")
In [1] : import pandas
Traceback (most recent call last):
File "<ipython-input-1-38d4b0363d82>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
In [2] :
Note: I have installed python in "C:\Users\me\AppData\Local\Programs\Python\Python37\" path and environment variables is set as "C:\Users\me\AppData\Local\Programs\Python\Python37;"
And I installed pandas using PIP
Please suggest the solution to resolve this issue.I have tried reinstalling the pandas package almost 6-7 times.
I think you should open anaconda command prompt by searching it in windows search bar . Now write there "conda install -c anaconda pandas" and try again to run the program

How to install omniORB for python3?

I could get omniORB running in python2.7 by just executing the configure script.
ubuntu#ubuntu:/usr/local/bin$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
ubuntu#ubuntu:/usr/local/bin$ python2
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import omniORB
>>>
However, running
../configure PYTHON=/usr/bin/python3
didn't do the trick for python3:
ubuntu#ubuntu:/usr/local/bin$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import omniORB
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'omniORB'
>>>
When running ../configure without any options, the script outputs:
...
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... linux2
...
When running ../configure PYTHON=/usr/bin/python3 , the script outputs:
...
checking for python version... 3.5
checking for python platform... linux
checking for python script directory... ${prefix}/lib/python3.5/site-packages
...
I'm using ubuntu 16.04 and the latest omniorb 4.2.2.
I also faced same problem too (I'm using ubuntu 18.04 and omniORB 4.2.3).
In my case, omniORBpy was installed in /usr/local/lib/python3.6/site-packages, but the directory is not in python's sys.path.
You should check sys.path and where omniORBpy is installed.

Error importing psycopg2._psycopg when run through cron

When I run the Python interperter directly, I have no problem with importing psycopg2
Python 3.5.1 |Anaconda custom (64-bit)| (default, Dec 7 2015, 11:16:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> from psycopg2._psycopg import *
>>>
But if I run import psycopg2 in a script executed through cron, I get the following error. How can I fix that so that it can run though cron as well?
import psycopg2, psycopg2.extras
File "/opt/anaconda3/lib/python3.5/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No module named _psycopg
As you can see, I am on Python 3.5 via Anaconda

Resources