Error when importing flask.ext.markdown - python

I have the following code :
#!/usr/bin/env python2
#coding: utf-8
from flask import Flask, render_template
from flask.ext.flatpages import FlatPages
from flask.ext.markdown import Markdown
But when I try to run it, this error occurs : ImportError: No module named flask.ext.markdown whereas normally this module is existing.
Is there somebody who can say how to fix that ?

It seems you need to install the flask-markdown plugin.
http://pythonhosted.org/Flask-Markdown/
You can install this with pip:
pip install flask-markdown
alternatively:
easy_install flask-markdown
If it is already installed try downloading the source and importing it directly.

That module hasn't been updated in over 3 years and uses the old flask extension API. There is a newer package called flask-markdown2.

Related

Pylint error: no name in module when import a package

I'm learning a little bit how function python, more specific Flask.
I'm creating a new project using flask, but when I create a new file and import Flask I receive this error: No name 'Flask' in module 'flask'pylint(no-name-in-module)
I did read that, I need create a file called: __init__.py but I have this and the error keeps showing up.
This is my actual code (very simple code, and folder/files structure):
Thanks for the help! :D
I tried this: Flask ImportError: No Module Named Flask, but this solution does not works for me.
I installed flask on python 2.7 and run simple hello world script and it worked fine. Then I updated python to python 3.8 and I got an error similar to yours:
Unable to import 'flask'pylint(import-error)
I simply uninstalled flask and installed again and it worked for me. Run this two commands:
pip uninstall flask
pip install flask
Then export the FLASK_APP environment variable and run flask
set FLASK_APP=file.py
flask run
I solved this changing my python interpreter. I did uninstall pylint and install pylama and now all is fine!

Error while importing pyVim.connect

I am attempting to run the following code which I received from samples here
from __future__ import print_function
import atexit
from pyVim.connect import SmartConnectNoSSL, Disconnect
from pyVmomi import vim
from tools import cli
I am receiving the following error:
ModuleNotFoundError: No Module named 'pyVim.connect'
The packages in question are from here and were installed using:
pip install pyvmomi
Is there something wrong with how I am installing these packages?
Looks like the code was a bit old. Importing 'pyvim' instead of 'pyVim' worked, though it seems to be named 'pyVim' on the github.
It's possible that you need to reinstall pvmomi to force the re-install of additional files in the pyVim/ package dir:
pip3 install --force pyvmomi
I haven't figured out how or what causes this, but the issue seems to occur on case-insensitive macOS file systems.
Since it has different behavior than Linux and case-sensitive macOS, I use the following "hack" to make it compatible between systems:
try:
from pyVim.connect import SmartConnectNoSSL
except ImportError:
from pyvim.connect import SmartConnectNoSSL
PS: You can use diskutil info / on macOS to figure out if your file system is case-sensitive or not (Details in another StackExchange question)

pytest fails to import module installed via pip and containing underscores

I am used to see import errors of my own modules.
But this time, this is about modules installed via pip and located in site-packages.
Here is a test file expurged from everything but just the imports :
import flask
import pygments
from flask_restful import Resource, Api
#from weather_tool import *
#from flask_restless import *
while running pytest :
Traceback:
test_MonAPPflaskRest.py:3: in <module>
from flask_restful import Resource, Api
E ModuleNotFoundError: No module named 'flask_restful'
Actually, every module with an underscore will fail !!!
flask_restless will fail to import to.
But it work when executed outside of pytest, or simply on the python shell...
Ok, I went through it.
Actually, Anaconda was installed. From here, no problem with that.
I installed Python from source as I'm used to do on a Linux platform and it works normally as expected.
I found out that pytest was not is the list of packages installed via pip.
Seems Anaconda provides a default pytest install. Maybe something is wrong with this version. (which pytest will return a pystest file in the python bin directory.
Actually, a simple pip install pytest in your virtualenv will 'overwrite' this - maybe messy - pytest version.
However calling pytest won't still work. You have to user py.test.
I know this is pretty much empirical. But that's it...
I got a similar error while importing stocker (Unable to find stocker module).
Try adding your 'code directory' to 'sys.path' where python looks for modules and it should be able to import then.
For more details:
https://bic-berkeley.github.io/psych-214-fall-2016/sys_path.html
I used the code:
>>> import sys
>>> sys.path.append('code') # code = the directory where your module is saved
>>> # Now the import will work
>>> import a_module # a_module = the module you are trying to import
I also faced the same issue when installed in virtual environment. I've deactivated virtual environment, installed flask-restful from PIP and then activated virtual environment. The issue is resolved.

importerror: no module named flask.ext.script

In fact I cannot use any pakage now!
importerror: no module named flask.ext.script
importerror: no module named Pymongo
It seems that you virtual environment doesn't work. You've installed the flask-script package, but when you run the script, it still looks for it in C:\Python3.4. You may give us more info so that we can figure it out where is wrong. (How do you install it, how do you active the virtualenv, does reinstall virtualenv work, close the cmd shell and try again works?)
Also note that from flask.ext.extension import xxx is the old way to use the flask extension. Instead you should use from flask_script import Manager, Server if you are using the latest flask-script 2.0.5
If you are using the IDE such as pycharm, then maybe need to set the interpreter of python for the right version. Otherwise the packages that you have installed can not be used for the current project. I have also encountered such kind of questions until I set my IDE's interpreter to the Python 2.7.
Then you can freely import the flask_script
I think you should use python 2 to use this module flask.ext.script" because this is the old way of doing it, or you could install Flask-Script and import it this way from flask_script import ...
from flask.ext.extension import xxx is the old way of importing extensions ,now it's not working .You have to freeze first to outputs the package and its version installed in the current environment . Then you can check your module and import it as usual
e.g: -from flask_bcrypt import Bcrypt
#this import the Bcrypt from flask_bcrypt

Cannot import livestreamer module in python

I am new to python and just tried to import the live streamer module (http://livestreamer.readthedocs.org/en/latest/api.html) in Python.
The module is installed at:
/Library/Python/2.7/site-packages/livestreamer-1.8.0-py2.7.egg
My script is pretty much one line:
from livestreamer import Livestreamer
Error:
ImportError: cannot import name Livestreamer
I searched the web for similar issues, but couldn't find any related to this module, but apparently it's a circular dependent import...? I don't know how to fix this.
Note: My script works when it's just:
import livestreamer
I'd say the modules doesn't contain a class called Livestreamer, but the documentation says so.
Did you properly installed Livestreamer.? R u experienced any error ..?
Try running this command from the package
pip install setup.py

Categories