Markdown library isn't installed/urllib ImportError - python

I'm trying to use Markdown with Django as shown in this tutorial. I've got the library installed and configured in Django using django.contrib.markup, but when I go to a page using markup, I get:
Error in 'markdown' filter: The Python markdown library isn't installed.
Then, through the interpreter I try running import markdown, which results in the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/markdown/__init__.py", line 43, in <module>
from .treeprocessors import build_treeprocessors
File "/usr/lib/python2.7/site-packages/markdown/treeprocessors.py", line 2, in <module>
from . import inlinepatterns
File "/usr/lib/python2.7/site-packages/markdown/inlinepatterns.py", line 47, in <module>
from urllib.parse import urlparse, urlunparse
ImportError: No module named parse
The Python documentation, however, tells me that urlparse has been renamed to urllib.parse in Python 3, which doesn't make any sense, because the Markdown library was installed through pip2, which put in into the python2.7 site-packages directory.
Changing that one line, by the way, results in more import errors.

No idea how this happened, but reinstalling Markdown worked. In retrospect, I probably should have tried that first.

Related

dynamic module does not define module export function (PyInit_bz2)

I am using Python3.6 on CentOS linux and have created virtual environment using venv. I installed matplotlib using pip install matplotlib and it completed successfully. Now when I am trying to import matplotlib in python command line it is producing Import Error:
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/__init__.py", line 127, in <module>
from . import cbook
File "/home/yogeshs/Python3.6VE/lib/python3.6/site-packages/matplotlib/cbook/__init__.py", line 13, in <module>
import bz2
ImportError: dynamic module does not define module export function (PyInit_bz2)
>>>
I read almost all the answers on similar issues on Stackoverflow and tried to follow the steps but I am unable to to resolve this problem. Can somebody please guide me through this? Thank you in advance.

Python igraph import error on Windows

I've installed igraph form .whl file using pip install. When I was trying to test the correctness of installation
import igraph.test
igraph.test.test()
I got this error:
Traceback (most recent call last):
File "D:/Nauka/Praca-inzynierska/Barabasi-Albert.py", line 4, in <module>
import igraph.test
File "D:\Programy\Python 3.5\lib\site-packages\igraph\__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: No module named 'igraph._igraph'
(the same error pops out if I'm trying to import igraph not igraph.test).
I've tried adding path (I don't know if this is rigth):
import sys
sys.path.append ("D:/Programy/Python 3.5/Lib/site-packages/igraph")
but it didn't work.
One thing I discovered is that if I delete "__init__" file from igraph folder I can import igraph without error, but it doesn't work for igraph.test.
If it's relevant I have Python 2.7 installed on my machine alongside Python 3.5.
Thank you in advance for any help.

"ImportError: No module named PyQt42

I am trying to import spynner into my python program (import spynner) ... when I run the script, I receive the following error message:
Traceback (most recent call last):
File "C:\Users\Michael\Desktop\webscraper.py", line 2, in <module>
import spynner
File "build\bdist.win32\egg\spynner\__init__.py", line 2, in <module>
File "build\bdist.win32\egg\spynner\browser.py", line 52, in <module>
ImportError: No module named PyQt4
I then tried to install this module called PyQt4 (pip install PyQt4), which resulted in the following error message:
Could not find any downloads that satisfy the requirement Pyqt4
How can this problem be solved?
PyQt is available for download from Riverbank.
You can get PyQt4 here: http://www.riverbankcomputing.com/software/pyqt/download
They have links to both the source (so you can build it yourself) or binary packages.
If you need the PyQt documentation for the various classes the framework provides, you get get that from here

Selenium - no module named http.client

I just installed Selenium (from source) for Python 2.7.
When I try to import selenium, I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\__init__.py", line 16, in <module>
from .selenium import selenium
File "C:\Python27\lib\site-packages\selenium-2.25.0-py2.7.egg\selenium\selenium.py", line 19, in <module>
import http.client
ImportError: No module named http.client
What could be causing this? If I remember correctly, http.client is a python 3 module. Why is selenium trying to import it?
Thanks to the help of DSM, I figured it out. Because I had previously ran setup.py with a python3 executable by accident, the selenium build folder was populated with 2to3 converted code. When I later ran python27 setup.py install it ended up using the same build folder for the installation without overwriting its content. I ended up deleting the build folder and trying again, and it works.

ImportError: couldn't find library

I am encountering these errors frequently when I install python libraries and I'm wondering what I am doing wrong
the current example is the libchromaprint library
http://acoustid.org/chromaprint
I install it and everything, try to run the python example, get:
Traceback (most recent call last):
File "examples/fpwav.py", line 7, in <module>
import chromaprint
File "build/bdist.linux-x86_64/egg/chromaprint/__init__.py", line 24, in <module>
ImportError: couldn't find libchromaprint
and then when I check:
find /usr/local/lib/libch*
/usr/local/lib/libchromaprint.so
/usr/local/lib/libchromaprint.so.0
/usr/local/lib/libchromaprint.so.0.1.3
what am I doing wrong?
Python does not use your usual library path. The chromaprint you're looking for should be somewhere like /usr/lib/pymodules/python2.6.
From the python interpreter do:
>>> import sys
>>> sys.path
This will show you the directories python searches for a module.

Categories

Resources