I asked a question here regarding installing the M2Crypto python library in Mint. That question was answered successfully and I was able to build and install M2Crypto. However, I am not able to use it within Python. when I attempt to import the module, I get the following error:
>>> import M2Crypto
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/M2Crypto/__init__.py", line 22, in <module>
import __m2crypto
ImportError: /usr/local/lib/python2.7/dist-packages/M2Crypto/__m2crypto.so: undefined symbol: SSLv2_method
If anyone know how to resolve this error, please let me know.
After two years the problem in m2crypto0.21.1 still exists, so here is a note for Ubuntu users. If you're not using virtualenv, you can easily fix it by installing m2crypto from Ubuntu PPA instead of pip:
sudo pip uninstall m2crypto
sudo apt-get install python-m2crypto
Seems like the problem is fixed in the PPA, but not in the project's repo. At least it worked for me at Ubuntu 12.04.
To expand the answer above:
This is a bug in M2Crypto 0.21.1. It has to do with the fact that SSLv2 was removed from OpenSSL on many platforms on the grounds of it being too insecure, notably Debian [1] and Ubuntu.
The removal is not detected during compile. There is a widely available patch that fixes this. I incorporated this into the M2Crypto source code on Github.
You can use pip to install directly from the repository like so:
pip install -e git+https://github.com/Hypernode/m2crypto#egg=M2Crypto
For those who want to inspect the (much published) patch that fixes this: b432d36
Edit: moved to another location
It looks like it is a bug introduced in M2Crypto 0.21.1, there is a patch here that correct the problem.
Maybe you could try to install an old version of M2Crypto (like the 0.20.1-1.1) or apply the patch manually with the patch command.
Related
I am trying to get the JapaneseTokenizer working in python, but I am having trouble with one of the modules it depends on. Here is the trace of the errors I am getting:
/Users/home/PycharmProjects/SubLingo/application/tokenizerTest.py
Traceback (most recent call last):
File "/Users/home/PycharmProjects/SubLingo/application/tokenizerTest.py", line 1, in <module>
import JapaneseTokenizer
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/__init__.py", line 6, in <module>
from JapaneseTokenizer.jumanpp_wrapper import JumanppWrapper
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/jumanpp_wrapper/__init__.py", line 1, in <module>
from .jumanpp_wrapper import JumanppWrapper
File "/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/JapaneseTokenizer/jumanpp_wrapper/jumanpp_wrapper.py", line 2, in <module>
from pyknp import Jumanpp
ImportError: cannot import name 'Jumanpp' from 'pyknp' (/Users/home/PycharmProjects/SubLingo/venv/lib/python3.7/site-packages/pyknp/__init__.py)
As you can see Jumanpp_wrapper is trying to import the module Jumanpp from pyknp. I have looked into the pyknp package currently installed on my machine and it does not have a module with this name. This leads me to conclude that the version of pyknp I have installed is not compatible with Jumanpp, so there must be another version available somewhere. The trouble is I install pyknp using the pip installer on my Mac, as recommended on the pyknp official site, so it should be the most current version. I'm not sure how to get an alternative version that contains the necessary module. I hope someone can point me in the right direction.
I'm a developer of the package. I kindly thank you for using my package.
I fixed bugs related to the issues here and released newer package version 1.4.
https://github.com/Kensuke-Mitsuzawa/JapaneseTokenizers/releases/tag/1.4
You could install/upgrade the package with pip also.
Install pip install JapaneseTokenizer / Upgrade pip install -U JapaneseTokenizer
I have been in direct contact with the developer of JapaneseTokenizer who has kindly given permission for me to repost his answer to my query:
I'm glad that you sent me a message about the issue. I read your post at StackOverflow. As other user suggested, the main issue is that pyknp package does not have juman++ module. I don't know the reason, but an author of pyknp package removed module for juman++.
The straightforward way to solve this issue is that you install pyknp package version 3 from here and install it your environment.
The main procedure is below.
remove pyknp package from your environment pip uninstall pyknp
get download pyknp package previous version. http://nlp.ist.i.kyoto-u.ac.jp/DLcounter/lime.cgi?down=http://lotus.kuee.kyoto-u.ac.jp/nl-resource/pyknp/pyknp-0.3.tar.gz&name=pyknp-0.3.tar.gz
install the pyknp=0.3 with pip install pyknp-0.3.tar.gz
From now, I revise JapaneseTokenizer package. It might take some weeks. Next time you try to install JapaneseTokenizer package, everything will be fine.
Again, thanks for giving me a message.
Best,
Kensuke Mitsuzawa
I removed numpy and scipy contents from the system's Python 2.6.4 in order to install different versions for them and now I broke YUM. The error I get is the following:
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named rpm
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.6.4 (r264:75706, Jun 4 2010, 18:20:31)
[GCC 4.4.4 20100503 (Red Hat 4.4.4-2)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
Also when I import YUM from inside the python console I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 23, in <module>
import rpm ImportError:
No module named rpm
Python is working fine and I managed to install numpy however I want to install scipy using YUM and I can't. Also when I run:
rpm --version
I get: RPM version 4.8.1.
Is there a way to solve this issue? I would be grateful for any advice or pointers towards solving this issue.
It looks like you don't have rpm-python installed. If yum was previously working, then it is difficult to see how the rpm module is not installed. Take a look in /usr/lib/python2.6/site-packages/rpm - that directory should exist, and should contain a couple of python files (__init__.py and transaction.py) and a shared library for rpm.
If the /usr/lib/python2.6/site-packages/rpm directory or the files are missing then you could try to install it. First check whether it is in the RPM database using rpm -q rpm-python. If it not installed then you can get the rpm from somewhere like this mirror and install it (rpm -ivh http://mirror.as24220.net/pub/fedora/linux/releases/20/Fedora/i386/os/Packages/r/rpm-python-4.11.1-7.fc20.i686.rpm). You will need to find the correct version for your Fedora and machine architecture.
More likely it will be (apparently) installed, in which case you could try force a reinstallation. Just be certain that you have access to the correct rpm of the same identical version, download it to be sure. If you are confident, then install with rpm -ivh --force rpm_file.
Then run python and see if you can import rpm and import yum.
Using Python 2.7 with scikit-learn 0.14 package. It runs well on some examples from the user guild expect the Linear Models.
Traceback (most recent call last):
File "E:\P\plot_ols.py", line 28, in <module>
from sklearn import datasets, linear_model
File "C:\Python27\lib\site-packages\sklearn\linear_model\__init__.py", line 12, in <module>
from .base import LinearRegression
File "C:\Python27\lib\site-packages\sklearn\linear_model\base.py", line 29, in <module>
from ..utils.sparsefuncs import mean_variance_axis0, inplace_column_scale
ImportError: cannot import name inplace_column_scale
Thank you~
I was able to fix this by going to my python folder and deleting the file:
python27\Lib\site-packages\sklearn\utils\sparsefuncs.pyd
My guess is that the problem was:
An older version of scikit-learn implemented sparsefuncs as a windows DLL
The current version implements it as a python file
If you install a new version on top of an old version it does not delete the old DLL
When you try to import, Python uses the pyd in preference to the py implementation
But the old implementation did not include this function
This suggests that there might be bigger problems caused by installing a new version and it might be wise to delete the whole sklearn directory before reinstalling the new version.
I encountered the same issue in Mac Os.
I solved it by deleting the file manually:
rm /usr/local/lib/python2.7/site-packages/sklearn/utils/sparsefuncs.so
Uninstalling scikit-learn and reinstalling it was the only option that worked for me:
pip uninstall scikit-learn
pip install scikit-learn
I solve this problem by :
pip uninstall scikit-learn
and don't forget to rm the 'sklearn' folder in the python 'site-packages'
rm -rf /path/Python-2.7.5/lib/python2.7/site-packages/sklearn/
then reinstall the package:
pip install scikit-learn
On a related note, this has been posted as a bug on the official Github page, along with some additional solutions, basically suggesting the same solutions as above. Long story short: run a make clean to get rid of the .so file.
I had the same problem. I had originally installed scikit-learn by:
sudo apt-get install python-sklearn
When none of the other solutions posted here worked, I decided to uninstall my version of scikit-learn and reinstall it:
pip2 install --user --install-option="--prefix=" -U scikit-learn
Used pip2 because I have two versions of python, so I use scikit-learn in Python 2.7
same problem happened with can not import _safe_split, have a look
http://stackoverflow.com/questions/41024001/importerror-cannot-import-name-safe-split
https://github.com/scikit-learn/scikit-learn/issues/7582
EDIT: check comment by Andreas Mueller
I am currently writing a python 3 program that parses through certain docx files and extracts the text and images from them. I have been trying to use docx but it will not import into my program. I have installed lxml, Pillow, and python-docx yet it does not import. When I try to use python-docx from the terminal I cannot use example-extracttext.py or example-makedocument.py which brings me to believe that the installation didn't run properly. Is there a way I can check if this installed correctly or is there a way to get this working properly so I can import it into my project? I am on Ubuntu 13.10.
I recommend you try the latest version of python-docx which is installed like this:
$ pip install python-docx
Documentation is available here: http://python-docx.readthedocs.org/
Installation should result in a message that looks successful. It's possible you'll need to install using sudo to temporarily assume root privileges:
$ sudo pip install python-docx
After installation you should be able to do the following in the Python interpreter:
>>> from docx import Document
>>>
If instead you get something like this, the install didn't go properly:
>>> from docx import Document
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named docx
As you can provide more feedback on your attempts I can elaborate the answer.
Note that after v0.2.x the python-docx package was rewritten. The API of v0.3.x+ is different as well as the package name and repository location. All further development will be on the new version. If you're just starting out with the package going with the latest is probably a good idea as the old one will just be receiving legacy support going forward.
Also, the Python 3 support was added with v0.3.0. Prior versions are not Python 3 compatible.
you can solve your import problem by first uninstalling the existant installation and then install it with pip3. solved my problem with this
pip uninstall python-docx
pip3 install python-docx
Use Command- sudo pip install --pre python-docx for the latest version of python-docx.
I am new to stackoverflow as well as Python, and I hope to use stackoverflow to learn and improve my Python programming.
However, as soon as I set up Python, SciPy, NumPy on my Mac, I encountered a problem when I tried running a full test of SciPy and NumPy to verify the install:
>>> import scipy
>>> scipy.test()
Running unit tests for scipy
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
scipy.test()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 318, in test
self._show_system_info()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 187, in _show_system_info
nose = import_nose()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/testing/nosetester.py", line 69, in import_nose
raise ImportError(msg)
ImportError: Need nose >= 0.10.0 for tests - see http://somethingaboutorange.com/mrl/projects/nose
As suggested by the error message, I install this 'nose' package via easy_install, and the install seems successful as I get the following from bash:
mlstr:~ mlstr$ nosetests -V
nosetests version 1.1.2
So I tried the SciPy test again, and it failed with the same message. Can someone please let me know if I need to do anything else to install/configure nose so that it can be used by the unit tests of SciPy and NumPy. Thanks in advance.
UPDATE #1: After trying Rahul's suggestion of using pip to reinstall nose, I think I've found where the problem is: whenever I do easy_install or pip from bash, the package is installed into Python 2.6 directories instead of 2.7 ones. And I think this is because by default 2.6 is the one shipped with Snow Leopard. So what should I do to tell easy_install or pip that I want to install a particular package for Python 2.7? Thanks.
UPDATE #2: By following up my update above, I've found the solution here: easy_install with various versions of python installed, mac osx. It is indeed because that I used the wrong version of easy_install thus my nose installation was for Python 2.6 shipped with Mac OS X. Thanks.
I tried replicating the error that you were encountering. I did not have nose, so I was getting the same error.
I installed nose using pip
sudo pip install nose
After that the scipy.test() worked. I did nothing else. Did you install nose using pip? If not, try using pip.
My machine has :
SciPy version 0.10.0.dev
Nose - 1.1.2
If you want to use your locally installed python version you need to make sure, that this is called when you run python from console.
On a linux machine an alias would do that. Once you run the correct python from your console all the easy_install things will be available in the correct python version.