simpleldap import missing module error - python

The following are output of trace when I have tried to install ldap with pip.
[root#reports-hammer-local tests]# pip install simpleldap
Requirement already satisfied (use --upgrade to upgrade): simpleldap in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): python-ldap in /usr/local/lib/python2.7/site-packages (from simpleldap)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages/setuptools-1.4.2-py2.7.egg (from python-ldap->simpleldap)
Cleaning up...
[root#reports-hammer-local tests]# python tests.py
Traceback (most recent call last):
File "tests.py", line 7, in `
import simpleldap`
ImportError: No module named simpleldap
I can't run the test because of missing module issues. can you please hep me to fix this.

Related

Python3 script installed with pip doesn't work

I installed an application with python's "pip":
sudo pip install EasyBlogger
Installation finished without errors:
Collecting EasyBlogger
Using cached EasyBlogger-0.9.0.zip
Requirement already satisfied (use --upgrade to upgrade): pypandoc in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): google-api-python-client in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): python-gflags in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): httplib2 in /usr/lib/python3.5/site-packages (from EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/lib/python3.5/site-packages (from pypandoc->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): oauth2client>=1.4.6 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): six>=1.6.1 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): uritemplate>=0.6 in /usr/lib/python3.5/site-packages (from google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.7 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules>=0.0.5 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): rsa>=3.1.4 in /usr/lib/python3.5/site-packages (from oauth2client>=1.4.6->google-api-python-client->EasyBlogger)
Requirement already satisfied (use --upgrade to upgrade): simplejson>=2.5.0 in /usr/lib/python3.5/site-packages (from uritemplate>=0.6->google-api-python-client->EasyBlogger)
Installing collected packages: EasyBlogger
Running setup.py install for EasyBlogger
Successfully installed EasyBlogger-0.9.0
However when I try to run the scipt the following way:
sudo easyblogger --blogid 6852822618950333369 get
I get only error messages:
Traceback (most recent call last):
File "/usr/bin/easyblogger", line 9, in <module>
load_entry_point('EasyBlogger==0.9.0', 'console_scripts', 'easyblogger')()
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 568, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2720, in load_entry_point
return ep.load()
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2380, in load
return self.resolve()
File "/usr/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2386, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.5/site-packages/blogger/__init__.py", line 1, in <module>
from blogger import EasyBlogger, main
ImportError: cannot import name 'EasyBlogger'
The content of /usr/bin/easyblogger is the following:
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'EasyBlogger==0.9.0','console_scripts','easyblogger'
__requires__ = 'EasyBlogger==0.9.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('EasyBlogger==0.9.0', 'console_scripts', 'easyblogger')()
)
The error comes from the 9. line load_entry_point. What can I do to make the easyblogger script working? Anyway I am using Arch Linux.
I see you're using Python 3. It appears easyblogger is not compatible, even though it installs using pip3.
To see this, correct __init__.py by adding a period since your are importing from the current folder (new in python 3):
from .blogger import EasyBlogger, main
Now if you run your command, you get the following:
File "/usr/local/lib/python3.4/dist-packages/blogger/blogger.py", line 424
print postId
^
SyntaxError: Missing parentheses in call to 'print'
Now you need to decide whether to fix the package or not! Just to make sure, installing in Python 3:
sudo apt-get -y install python3-setuptools
sudo easy_install3 pip
sudo pip3 install EasyBlogger

scrapy can't load libxslt.1.dylib on my mac

I use pip install scrapy to install scrapy
But I run scrapy get below error:
➜ source scrapy
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 7, in <module>
from scrapy.cmdline import execute
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in <module>
from scrapy.spiders import Spider
File "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/Library/Python/2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/Library/Python/2.7/site-packages/lxml/html/__init__.py", line 42, in <module>
from lxml import etree
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: /opt/local/lib/libxslt.1.dylib
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Reason: image not found
It's strange scrapy look for libxslt.1.dylib in my /opt/ floder...
And I run pip install scrapy, get this:
➜ ~ pip install scrapy
Requirement already satisfied (use --upgrade to upgrade): scrapy in /Library/Python/2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): queuelib in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.8.0 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): lxml in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): service-identity in /Library/Python/2.7/site-packages (from scrapy)
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /Library/Python/2.7/site-packages (from Twisted>=10.0.0->scrapy)
Requirement already satisfied (use --upgrade to upgrade): characteristic>=14.0.0 in /Library/Python/2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules in /Library/Python/2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from service-identity->scrapy)
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.1.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy)
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=1.1.0->cryptography>=0.7->pyOpenSSL->scrapy)
Help!!
Update in 2015/11/06
Hi, Joe Young.
I have try this brew install libxml2 libxslt.But it doesn't work, It seems like my python's look path is wrong?
➜ haimi git:(V3.2.0) brew install libxml2 libxslt
Warning: libxml2-2.9.2 already installed
Warning: libxslt-1.1.28_1 already installed
➜ haimi git:(V3.2.0) ✗ scrapy
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 7, in <module>
from scrapy.cmdline import execute
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in <module>
from scrapy.spiders import Spider
File "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module>
from scrapy.http import Request
File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 11, in <module>
from scrapy.http.request.form import FormRequest
File "/Library/Python/2.7/site-packages/scrapy/http/request/form.py", line 9, in <module>
import lxml.html
File "/Library/Python/2.7/site-packages/lxml/html/__init__.py", line 42, in <module>
from lxml import etree
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: /opt/local/lib/libxslt.1.dylib
Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so
Reason: image not found
➜ haimi git:(V3.2.0) ✗
It sounds like you need the libxslt and libxml libraries which are required by the lxml python package, which is required by scrapy.
If you install the "X-code Command Line Tool package", it should include these libraries for you. There's a guide here: http://quantgreeks.com/how-to-install-xcode-command-line-tools-in-osx-yosemite/
Essentially it boils down to running:
xcode-select --install

Modified dependencies in python package do not show up

In a Python package I have, in setup.py I modified the dependencies by removing the condition on the version number:
setup(
name='MyTool',
version='0.1.5',
author='myname',
author_email='myname#myname.com',
packages=['mytool'],
scripts=['bin/my_tool.py'],
url='https://pypi.python.org/pypi/mytool',
license='LICENSE.txt',
description='This is my tool.',
long_description=open('README.txt').read(),
install_requires=[
"scipy",
"numpy",
"prettytable"
],
)
I ran:
$ python setup.py sdist
$ python setup.py sdist upload
But when I run pip, it refers to the previous requirements:
$ sudo pip install MyTool
Requirement already satisfied (use --upgrade to upgrade): MyTool in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): scipy>=0.7.0 in /usr/local/lib/python2.7/dist-packages (from MyTool)
Requirement already satisfied (use --upgrade to upgrade): numpy in /usr/local/lib/python2.7/dist-packages (from MyTool)
Requirement already satisfied (use --upgrade to upgrade): prettytable>=0.7.2 in /usr/local/lib/python2.7/dist-packages (from MyTool)
Cleaning up...
What did I do wrong?
That means you have already installed package MyTool.
If you want to install the latest version (the uploaded version just now), try:
sudo pip install -U MyTool

Running fab sanity gives an error: no module named quilt

I an now setting up a work environment on some open source project I just cloned from GitHub,
after running
pip install -U -r requirements.txt
in a virtualenv of course, I was trying to run fab sanity as this projects uses fabric, and I am getting the following error:
(openmuni)oleg#oleg-Lenovo-G580:~/dev/openmuni-budgets$ fab sanity
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/fabric/main.py", line 637, in main
docstring, callables, default = load_fabfile(fabfile)
File "/usr/lib/python2.7/dist-packages/fabric/main.py", line 164, in load_fabfile
imported = importer(os.path.splitext(fabfile)[0])
File "/home/oleg/dev/openmuni-budgets/fabfile/__init__.py", line 1, in <module>
from quilt import *
ImportError: No module named quilt
The most trivial 2 solutions didn't work unfortunately:
(openmuni)oleg#oleg-Lenovo-G580:~/dev/openmuni-budgets$ pip install quilt
Requirement already satisfied (use --upgrade to upgrade): quilt in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): Fabric>=1.8.0 in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages (from quilt)
Requirement already satisfied (use --upgrade to upgrade): cuisine>=0.6.5 in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages (from quilt)
Requirement already satisfied (use --upgrade to upgrade): paramiko>=1.10.0 in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages (from Fabric>=1.8.0->quilt)
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.1,!=2.4 in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages (from paramiko>=1.10.0->Fabric>=1.8.0->quilt)
Requirement already satisfied (use --upgrade to upgrade): ecdsa in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages (from paramiko>=1.10.0->Fabric>=1.8.0->quilt)
Cleaning up...
(openmuni)oleg#oleg-Lenovo-G580:~/dev/openmuni-budgets$ pip install python-quilt
Requirement already satisfied (use --upgrade to upgrade): python-quilt in /home/oleg/.virtualenvs/openmuni/lib/python2.7/site-packages
Cleaning up...
Running:
deavtivate
and then
pip install python-quilt solved it, but that means that quilt is now global and installed outside of the virtualenv, a bit of a hack.

Install module using pip within Anaconda environment

I've recently transitioned to an Anaconda environment on RHEL6, but I need a module not in the conda repository. So I install it with pip:
(gt_keys)[user#server gtkey]$ which pip
/srv/home/shared/anaconda/envs/gt_keys/bin/pip
(gt_keys)[user#server gtkey]$ pip install owslib
Downloading/unpacking owslib
Downloading OWSLib-0.8.3.tar.gz (97kB): 97kB downloaded
Running setup.py egg_info for package owslib
Requirement already satisfied (use --upgrade to upgrade): python-dateutil>=1.5 in /srv/home/shared/anaconda/lib/python2.7/site-packages (from owslib)
Requirement already satisfied (use --upgrade to upgrade): pytz in /srv/home/shared/anaconda/lib/python2.7/site-packages (from owslib)
Requirement already satisfied (use --upgrade to upgrade): pytest in /srv/home/shared/anaconda/lib/python2.7/site-packages (from owslib)
Requirement already satisfied (use --upgrade to upgrade): pytest-cov in /srv/home/shared/anaconda/lib/python2.7/site-packages (from owslib)
Requirement already satisfied (use --upgrade to upgrade): PIL in /srv/home/shared/anaconda/lib/python2.7/site-packages/PIL (from owslib)
Requirement already satisfied (use --upgrade to upgrade): cov-core>=1.6 in /srv/home/shared/anaconda/lib/python2.7/site-packages (from pytest-cov->owslib)
Requirement already satisfied (use --upgrade to upgrade): coverage>=3.4 in /srv/home/shared/anaconda/lib/python2.7/site-packages (from cov-core>=1.6->pytest-cov->owslib)
Installing collected packages: owslib
Running setup.py install for owslib
Successfully installed owslib
Cleaning up...
But it doesn't work in my environment:
(gt_keys)[user#server gtkey]$ which python
/srv/home/shared/anaconda/envs/gt_keys/bin/python
(gt_keys)[user#server gtkey]$ python -c 'import owslib'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named owslib
owslib only made it to the base Ananaconda install:
sh-4.1$ which python
/srv/home/shared/anaconda/bin/python
sh-4.1$ python -c 'import owslib'
What am I doing wrong?
I don't know why, but this time it worked:
pip install owslib --allow-external PIL --allow-unverified PIL
I would be interested, still, in any comments on my process. Something strange was happening that was resolved when I reconnected to the server this morning after failing last night. Must be something with the path.

Categories

Resources