I'm trying to build a SAML authentication mechanism in Python using the OneLogin module, but I can't even get started. Trying from the example code provided in the docs, I can't even load the package.
This works:
import onelogin
but this gets a ModuleNotFoundError:
>>> from onelogin.saml2.auth import OneLogin_Saml2_Auth
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'onelogin.saml2'
I only managed to get this working on a Linux machine, so hope you're not on windows. Here's what worked for me.
I had to do a seperate install of hte xmlsec-library first:
apt-get install xmlsec1 openssl python-lxml libxmlsec1 libxmlsec1-dev
and then I was able to
pip install python3-saml
and there were no complains anymore.
You need to install Xmlsec first and then python3-saml but if you are on Windows, Xmlsec has some issues but as with python 3.6 and below the problem is solved. Use this link to download the wheel file for your python version https://github.com/mehcode/python-xmlsec/releases
Install the wheel file using
pip install <wheel_file_name>
As with Python 3.7, the only way out is to install xmlsec on a Linux machine as it is not yet supported on Windows.
Related
I am using Ubuntu 18.04. If I install libcurl4 (instead of libcurl3), when I import pycurl installed with pipenv I get
>>> import pycurl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/pietro/envs/try_fabric-kcbGLH3z/lib/python3.6/site-packages/pycurl.cpython-36m-x86_64-linux-gnu.so)
Note that this error is raised only when I use a pycurl installed with pipenv or pip. If I use instead pycurl installed through apt on system python there are any errors...
What can I do to avoid this impasse?
I assume you upgraded your operating system recently.
pip stores a cache of built wheels in your home directory, when upgrading your os it is a good idea to clear this cache as the binaries may now link against incompatible system libraries
You can do this by rm -rf ~/.cache/pip and then recreate your environment
I've just upgraded to Fedora 27, and have been unable to get psycopg2 working.
I'd very much appreciate any help anyone can provide.
As a simple test case, I've been executing
>>> import psycopg2
at the interactive shell. This works fine for Python 2.7, but fails for Python 3.x.
With Python 3.4 and 3.5, I get the message:
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named 'psycopg2'
With Python 3.6, I see:
Traceback (most recent call last):
File "", line 1, in
File "/home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/init.py", line 50, in
from psycopg2._psycopg import ( # noqa
ImportError: /home/jazcap53/.local/lib/python3.6/site-packages/psycopg2/.libs/libresolv-2-c4c53def.5.so: symbol __res_maybe_init, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
I installed Fedora 27 from DVD-ROM. I find psycopg2 packages located at
/usr/lib64/python2.7/site-packages
and
/home/jazcap53/.local/lib/python3.6/site-packages
My Python packages were all either included with Fedora, or installed via dnf. They are:
python3-3.6.3-2.fc27.x86_64
python35-3.5.4-1.fc27.x86_64
python34-3.4.7-1.fc27.x86_64
python2-2.7.14-2.fc27.x86_64
Some packages I have installed that may be relevant are:
python2-devel-2.7.14-2.fc27.x86_64
python3-devel-3.6.3-2.fc27.x86_64
libpqxx-1:5.0.1-2.f27.x86_64
libpqxx-devel-1:5.0.1-2.f27.x86_64
libgcc-7.2.1-2.fc27.x86_64
postgresql-devel-9.6.6-1.fc27.x86_64
P.S.: If I'm asking this question in the wrong place, please direct me to the right place.
Edit:
I noticed that:
/usr/lib64/python2.7/site-packages/
contains subdirectories
psycopg2 and
psycopg2-2.7.3-py2.7.egg-info
but
/usr/lib64/python3.4/site-packages/ and
/usr/lib64/python3.5/site-packages/
contain nothing related to psycopg2
and
/usr/lib64/python3.6/site-packages/
contains subdirectory
psycopg2-2.7.3-py3.6.egg-info
but not psycopg2 itself
As you may have noticed, each version of Python has its own package hierarchy. So the installation on Python 3.6 will not give you access on 3.4 and 3.5.
With that said, there seems to be some problem with the system's standard lib with Python 3.6. One solution to that could be to install without binaries, like this:
python3.6 -m pip uninstall psycopg2
python3.6 -m pip install --no-binary :all: psycopg2
To install psycopg2 on 3.4 and 3.5 you would run these with or without the --no-binary option:
python3.4 -m pip install psycopg2
python3.5 -m pip install psycopg2
If you have automatic installs / docker install you need to ensure you add the following line to requirements.txt to ensure psycopg2 installs from source, rather than using the binary, or you'll continue to experience the above issue upon deployment.
psycopg2>=2.7,<2.8 --no-binary psycopg2
Update 2:
the main problem turned out to be a different one from what I had thought it was, and asked for help here. I moved the new question to a new post:
Install custom python package in virtualenv
Update:
ok, so I screwed up my non-virtualenv by accident.
The non-virtualenv (normal bash) I could easily fix by removing the manually installed (via pip) lxml and running
conda install lxml --force
But for some reason, that doesn't work in the virtualenv.
There, running
conda install lxml --force
works without error message, but when I run python and simply say
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named lxml
Any suggestions??
old message:
I'm trying to use virtualenv for my python flask application.
The python code runs perfectly fine without the virtualenv.
I've installed the packages I need in the virtualenv, but I after installing lxml via
pip install lxml
Installing collected packages: lxml
Successfully installed lxml-3.6.0
I get the following error message when running my code:
File "/Users/XXX/xxx/flask-aws/lib/python2.7/site-packages/docx-0.2.4-py2.7.egg/docx.py", line 17, in <module>
from lxml import etree
ImportError: dlopen(/Users/XXX/xxx/flask-aws/lib/python2.7/site-packages/lxml/etree.so, 2): Library not loaded: libxml2.2.dylib
Referenced from: /Users/XXX/xxx/flask-aws/lib/python2.7/site-packages/lxml/etree.so
Reason: Incompatible library version: etree.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0
I have seen other people report similar problems at stackoverflow, and one guy remarked that the problem might related to the virtualenv, but there was no solution.
Once again: The python code runs perfectly fine without virtualenv! But inside virtualenv, I can't get it to work.
I'm using Anaconda Python 2.7 on a Mac.
I'd appreciate any help guys!
I had the same error and stumbled upon this link, after searching for the incompatible library error "libxml2.2.dylib provides version 10.0.0"
Installing libxml2 that worked for me:
brew install libxml2
brew link --force libxml2
Solution that works for me in virtual environment is to force pip to recompile lxml:
pip install lxml --force-reinstall --ignore-installed --no-binary :all:
I am using Ubuntu 12.04.2 LTS. I have used libxml2 in my python script and when I try to run it, gives error
Traceback (most recent call last):
File "deploy.py", line 3, in <module>
import libxml2
ImportError: No module named libxml2
I tried almost all stackoverflow answers for the same question but nothings solves the issue (Installed several different packages).
You have to install the package in Ubuntu before being able to use it:
sudo apt-get install python-libxml2
You'd have to install python-libxml2.
Note that that's a fairly basic wrapper around the libxml2 C library. You may want to use lxml instead, for a far more Pythonic XML API.
You can try
pip install libxml2-python
Depending on which installation of Python I am using I have some problems to load a module. When I type
from quantecon import approx_markov
in the terminal using Python 3.4.0, the following error message is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
In the folder /usr/... as referred to above, I do however find a module called asset_pricing. (I have to admit that I additionally do not understand why the module asset_pricing interferes.)
I installed quantecon with:
pip3 install quantecon
I suspect that the problems are related to the Python version I am using. I also installed
pip install quantecon
and when I call the module approx_markov form the terminal, using Python 2.7.6 (I think this is the standard Python version of the OS I am using) I do not receive any error message. To solve the problem I already followed the instruction in the following discussion but to no avail Python3 has no acces to python2 modules (ubuntu).
The currently released version of quantecon is not Python 3 compatible; it uses relative imports and these are not supported anymore in Python 3.
The version in the source repository has been refactored and updated, and looks like it'll work with Python 3. You'll need to install that version instead:
pip3 install -U git+https://github.com/jstac/quant-econ.git
where -U tells pip3 to upgrade the package.
Note that there have been a lot of changes recently; use at your own risk. You could stick with Python 2 and wait for an official release.