简体   繁体   中英

How to install third party modules and libraries through flask web app

I'm trying to install the module mockupbase in order to import HTMLParser for my Flask Web App. Mockupbase is not a package/module within the Python Package Index, so pip install doesn't work in my visual studio development environment. The only resource I could find online about installing third party libraries was http://flask.pocoo.org/docs/0.10/extensiondev/ , but this link says extensions must be registered under the python package index. I feel like there should be an alternative route to installing third party packages without registering them on python package index. I'm familiar with installing packages on my local computer, but am not sure how to implement this on my flask web project.

How do I install a third party python module/library not registered on Python Package Index for my flask web application

It seems that we cannot install module mockupbase on VS using pip and easy_install . However, I have ever install custom module as following steps, you can try it. For example, I create a Hello.py file and store it into C:/Python folder. Then, I can use it via this method:

import sys
sys.path.append('c:/python')
import hello

hello.hello() # hello,world

For this issue, I recommend you refer to this documents: The module-search-path And you can see this post .

You can specify url, local file path, ... instead of package name. By specifying url, file path, pip will try to download it, unpack it and install it.

According to Installing Packages - User Guide - pip documentation ,

pip supports installing from PyPI, version control, local projects, and directly from distribution files .

If you have multiple packages, you can follow Fast & Local Installs :

Often, you will want a fast install from local archives, without probing PyPI.

First, download the archives that fulfill your requirements:

 $ pip install --download <DIR> -r requirements.txt 

Then, install using --find-links and --no-index:

 $ pip install --no-index --find-links=[file://]<DIR> -r requirements.txt 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM