ImportError: cannot import name Library, during installing PyLucene - python

I have spent 5 hours to fix this problem but I can't. During installing PyLucene with http://lucene.apache.org/pylucene/install.htmt , I faced with a error like follwing.
sanghee-m:jcc sanghee$ python setup.py build
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework
Traceback (most recent call last):
File "setup.py", line 398, in <module>
main('--debug' in sys.argv)
File "setup.py", line 306, in main
from setuptools import Library
ImportError: cannot import name Library
sanghee-m:jcc sanghee$ python setup.py build --debug
found JAVAFRAMEWORKS = /System/Library/Frameworks/JavaVM.framework
Traceback (most recent call last):
File "setup.py", line 398, in <module>
main('--debug' in sys.argv)
File "setup.py", line 306, in main
from setuptools import Library
ImportError: cannot import name Library
sanghee-m:jcc sanghee$
I can't find Library also. How can I solve this problme? Can you let me know where should I check when I get this kind of error?
Also, I installed setuptools 1.1.6 and used pylucene-4.4.0-1.
sanghee-m:jcc sanghee$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools

I am trying to compile JCC under windows, and I found that the latest version of setuptools, 1.1.6, gives the import error you reported. However with version 0.6c11 the Library module is found.
Edit: 1.1.3 also works.

it may seem like a stupid question but do you have the setuptools installed?
https://pypi.python.org/pypi/setuptools/0.6c11

Related

Importing psutil causes ImportError

I'm trying to get psutil to work on our server. It is running AIX. There is no pip. So, I downloaded the repo from github(AIX build of psutil), cd into it, and ran Python CLI.
Now, trying to do import psutil causes an ImportError.
bash-4.2$ python
Python 2.7.5 (default, Aug 16 2013, 14:02:06) [C] on aix6
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "psutil/__init__.py", line 163, in <module>
from . import _psaix as _psplatform
File "psutil/_psaix.py", line 20, in <module>
from . import _psutil_aix as cext
ImportError: cannot import name _psutil_aix
>>> import psutil ## IMPORTING AGAIN THE SAME SESSION CAUSES DIFFERENT ERROR
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "psutil\__init__.py", line 39, in <module>
from . import _common
ImportError: cannot import name _common
What can I do here? Installing the module locally using python setup.py install --user is also not working:
bash-4.2$ python setup.py install --user
running install
running build
running build_py
running build_ext
building 'psutil._psutil_aix' extension
xlc_r -ma -I/opt/freeware/include -DAIX_GENUINE_CPLUSCPLUS -Wl,-brtl -g -DNDEBUG -O2 -DPSUTIL_POSIX=1 -DPSUTIL_VERSION=532 -DPSUTIL_AIX=1 -I/opt/freeware/include/python2.7 -c psutil/_psutil_common.c -o build/temp.aix-7.1-2.7/psutil/_psutil_common.o
unable to execute xlc_r: No such file or directory
error: command 'xlc_r' failed with exit status 1
I've tried doing the same with the tweepy package which runs perfectly(given six, requests, and requests_oauthlib are already installed).
EDIT: Just to make clear this is not limited to AIX, I've tried doing the same on Windows, and it gives the same error.
AIX is currently not supported by psutil although it will in the next major release.
A possible solution could be downloading the wheel from PyPi
(psutil on PyPi)
Then open it with a zip program (7zip or similar).
In there should be a psutil folder. Place this folder next to your script and try to import it.

Pybrain not working with Python 3.6.1

I installed Python 3.6.1. And then installed pybrain using git (See Screen Shot). Then when I useimport pybrainit works but afterwards when I usefrom pybrain.tools.shortcuts import buildNetworkit gives me error that: Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pybrain
>>> from pybrain.tools.shortcuts import buildNetwork
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from pybrain.tools.shortcuts import buildNetwork
File "C:\Users\davm5\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pybrain\tools\shortcuts.py", line 14
except ImportError, e:
SyntaxError: invalid syntax.
>>> from pybrain.structure import TanhLayer
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from pybrain.structure import TanhLayer
File "C:\Users\davm5\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pybrain\structure\__init__.py", line 1, in <module>
from connections.__init__ import *
ModuleNotFoundError: No module named 'connections'
Why is it doing like this? Kindly help me out here. Thanks
EDIT: Excluded screen shots. Added everything in post as per request.
except ImportError, e is Python 2 syntax and you've tried to run the code with Python 3. Install the latest version — the code seems to be fixed in git (it's except ImportError as e now, so it's suitable for both Python 2.7 and Python 3).
Just an update: I was able to resolve the issue by un-installing python, then installing python 3.6.2 (64 bit), using pip3 (pip3 install pybrain) I was able to install the latest version of pybrain which worked flawlessly. Thanks to everyone who tried to help me out when I was fairly new to python. Love this community!!

easysnmp library doesn't work on el-capitan

I'm running OSX ElCapitan and I've brew install easysnmp... nevertheless, when I try to import it on python, I get the following error:
Python 2.7.12 (default, Jun 29 2016, 14:05:02)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from easysnmp import Session
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/easysnmp/__init__.py", line 1, in <module>
from .easy import ( # noqa
File "/usr/local/lib/python2.7/site-packages/easysnmp/easy.py", line 3, in <module>
from .session import Session
File "/usr/local/lib/python2.7/site-packages/easysnmp/session.py", line 8, in <module>
from . import interface
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/easysnmp/interface.so, 2): Symbol not found: _netsnmp_transport_config_compare
Referenced from: /usr/local/lib/python2.7/site-packages/easysnmp/interface.so
Expected in: flat namespace
in /usr/local/lib/python2.7/site-packages/easysnmp/interface.so
easysnmp sites state that it requires net-snmp 5.7 although el capitan is shipped with 5.6... so I've "brew installed" snmp-get 5.7.
Brew doesn't change the symlinks so I'm assuming python is still looking at version 5.6.
Install output :
==> make
==> make install
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
OS X already provides this software and installing another version in
the parallel can cause all kinds of trouble.
Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:
LDFLAGS: -L/usr/local/opt/net-snmp/lib
CPPFLAGS: -I/usr/local/opt/net-snmp/include
==> Summary
🍺 /usr/local/Cellar/net-snmp/5.7.3: 538 files, 12.8M, built in 4 minutes 34 seconds

Howto install psycopg2 in virtualenv with mx support?

I have a virtualenv venv where I installed mx-base and psycopg2 with pip:
$ pip freeze | grep "psyco\|mx"
egenix-mx-base==3.2.8
psycopg2==2.6
The basics of psycopg2 works but when using extensions I get exceptions like this:
Traceback (most recent call last):
File "/my_proj/my_code.py", line 32, in <module>
register_types()
File "/my_proj/my_code.py", line 28, in register_types
psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
AttributeError: 'module' object has no attribute 'MXDATETIME'
Or:
ulf#kalla:~(0)(venv)$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import psycopg2
>>> #Use mx.DateTime instead of pythons datetime, for compability reasons.
... psycopg2.extensions.register_type(psycopg2._psycopg.MXDATETIME)
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
AttributeError: 'module' object has no attribute 'MXDATETIME'
>>>
It seems that the installed version of psycopg2 lacks the mx-support.
How could I fix this?
You will probably need to build psycopg2 on your own, download the tar.gz, unzip, and then find the setup.cfg file, modify the mx_include parameter to be /lib/python2.7/site-packages/mx/DateTime/mxDateTime and then
python setup.py build_ext install

keep getting 'ImportError: No module named pygtk' when I try to run Gaphor on windows

I have installed pygtk-all-in-one-2.24.0.win32-py2.7.msi on windows, and installed gaphor by easy_install. When I try to run gaphor, I receive an import error.
PS C:\Python27\Scripts> .\gaphor.exe
Traceback (most recent call last):
File "C:\Python27\Scripts\gaphor-script.py", line 9, in <module>
load_entry_point('gaphor==0.17.2', 'console_scripts', 'gaphor')()
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 521, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2632, in load_entry_point
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2312, in load
File "build\bdist.win32\egg\pkg_resources\__init__.py", line 2318, in resolve
File "C:\Python27\lib\site-packages\gaphor-0.17.2-py2.7.egg\gaphor\__init__.py", line 13, in <module>
import pygtk
ImportError: No module named pygtk
Any suggestions would be appreciated!
Did you actually install pygtk? I suspect easy-install should have pulled it in automatically. Did you see any errors during the install? pygtk also requieres installing gtk+.
Do a simple test - start Python in a console (ipython?), and type:
$ python
Python 2.7.6 (default, May 6 2014, 10:57:58)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygtk
>>> import gtk
>>>
There should be no error messages.
You can also search the disk for pygtk.py (with the file manager) and for a directory gtk-2.0 or gtk-3.0.

Categories

Resources