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
Related
I want to deploy a python flask app using Amazon’s Elastic Beanstalk.
Therefore, I want to use virtualenv to make sure to get the right packages.
However, one package (docx) isn't available through pip and I'd like to install it manually.
If I do install it manually via python setup.py install the installation works, but the package screws up lxml dependencies.
Do I need the virtualenv in the first place, or can I also just log into the amazon console and install all packages manually?
I'm running a Mac at home, and linux on amazon's S3 server, so can building the package on my Mac (I think some c-code is compiled) work anyway?
If you do recommend to still use virtualenv, any idea of how to resolve the screwed up library issue above?
(if I am outside of the virtualenv and use conda install lxml, I'm good. But inside of virtualenv, conda install lxml will not install lxml for some reason, import lxml gives an error that the library isn't found.
I'd appreciate your input.
I am extremely new in python so i cant figure out a way to install a standalone python module hosted by a third party. Ex https://github.com/cvangysel/gitexd-drupalorg/tree/master/drupalorg
How to install this specific python module DrupalHash . Should i use pip ? I tried to read the documentation Installing Python Modules but i could not quite get it.
Any help ?
Seeing as the linked repo doesn't contain a setup.py, which would be required to install it with pip or easy_install, and the last commit was over 4 years ago, I'd just copy the drupalpass.py file into your local project and use it with a simple from drupalpass import DrupalHash.
The module you are linking doesn't seem to be available on PyPI, you will need to clone the repository to use the library.
For packages that may be available on PyPI, you can install pip:
easy_install pip
Then, you will be able to install your packages:
pip install *package name*
I am working in a team and wrote some python code that uses libraries that need to be installed separately (because they are not part of standard python distribution). How should I specify those ? What is the right/correct/pythonic way to do this?
I personally use pip install -r requirements.txt
https://pip.pypa.io/en/latest/user_guide.html#requirements-files
Check out tool called pip. It's what most python projects use these days.
Typically, one would do the following (for example, we want to install the requests package for our new project):
pip install requests
and then
pip freeze > requirements.txt
Now, we have installed requests on our system and saved the dependency version to a file which we can distribute with our project.
At this point, requirements.txt contains:
requests==2.7.0
To install the same set of requirements (in our case only the requests package) on some other system, one would do the following:
pip install -r requirements.txt
You need to make a setup.py file for your package that specifies required packages. You may need to reorganize your file structure and include data and a manifest.
Then create a distribution of your package, EG: a wheel file.
Then when using pip install your_package_distro.whl, pip will determine your packages dependencies are met and install them from PyPI unless you specify another package source (EG: https://pypi.anaconda.org/)
Read through the following references to distribute your code:
Python 2.7.10 documentation - Distributing Python Modules, Section 2: Writing the Setup Script
Setuptools - Building and Distributing Packages with Setuptools
Hitchhiker's Guide to Packaging
Hitchhiker's Guide to Python - Packaging your Code
I am trying to setup my project on web-fraction . My project using some external packages and when I installed them using pip they got installed in root lib dir i.e., $HOME/bin but my project is using python inside my app i.e., $HOME/webapp/app/bin . Now I simply wants that I can able to install packages inside my app i.e., inside webapp . I have used one command for this but that doesn't work :
pip-2.7 install --install-option="--install-script=$PWD/bin" --install-option="--install-lib=$PWD/lib/python2.7" package
I have read webfraction docs but I didn't get it right . So please tell me the steps how I can install packages inside webapp .
For instance, let's say you want to install django-haystack 2.0.0 on webfaction, using pip. You could do the following ($PWD does not work I think) :
pip-2.7 install django-haystack==2.0.0 --install-option="--install-scripts=/home/your_account/webapps/your_django_app/bin" --install-option="--install-lib=/home/your_account/webapps/your_django_app/lib/python2.7"
I'm new to Python so this may sound silly.
I want to use a Python library I've found on Github, lets say on https://github.com/praw-dev/praw, and I want to be able to do git pull in the future to pull the latest commits.
Question: Should I git clone <git url> in the project directory and delete everything except the praw directory, then in my python script do a import praw?
In iPython,
import praw
gives the error ImportError: No module named praw
Directory Structure
~\myProject\
praw\
myNotebook.ipynb
Actually, if given package is not on PyPI (or you want a specific branch) you can still install it through pip from GitHub with:
pip install git+https://github.com/[repo owner]/[repo]#[branch name]
And for your problem it would be (although #pandita's answer is correct for normal usage case):
pip install git+https://github.com/praw-dev/praw.git
For more information check this answer.
Experimental Python module finder/loader from github, like in golang.
So, in golang we can import like:
import "github.com/parnurzeal/gorequest"
But in python we should install package by our hands:
pip install requests
And import it like:
import requests
But with this magic package and power of PEP-0302 we can do it automatically:
from github_com.kennethreitz import requests
assert requests.get('https://github.com/nvbn/import_from_github_com').status_code == 200
Installation
You should have git, Python 3.2+ and pip:
pip install import_from_github_com
Reference: https://github.com/nvbn/import_from_github_com
Just clone the files in any dir on your python path and then build the lib typically with python setup.py install from the command line.
I typically clone a libray form git in my site_libraries folder ( the folder that holds all of your pip installed packages ). From there you can pull and then build the libraries from git just like any other git repo. Having the files there is nice because all of your libs are in once place on your python path.
You might want to consider using pip instead of git to install and upgrade the package (that is unless you have a pressing reason to use git).
pip install praw
to update the package you can do
pip install --upgrade praw
Also have a look here for further information on how to use pip.