Issues in installing packages on webfraction - python

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"

Related

How can i know the name of a imported module? PYTHON

i've installed a python project, and it imports modules(Like almost every project). The problem is when i want to install them(because i haven't got the modules), for example: In the project is imported a module called "a" but when i go and install "a" with pip install a, it says ERROR: Could not find a version that satisfies the requirement a (from versions: none) ERROR: No matching distribution found for a. How could i know the name of the module that is imported in that python project?
Edit:
btw i just found out the module that the project uses comes in the zip where the python project is. How could i install it so it works?
All pip packages are listed here. If you want to import a module called a inside a python script, the command to install it could be sometimes pip install b. Because the name of the stored package can varied from the python import name. To find how to install it the best is to get the pypi url of your package. You can googling the python error ModuleNotFoundError: No module named 'dgvd', it always show you the pypi url in top links.
The good practice in a project is to have a txt file called requirement.txt that you create in bash using this command:
pip freeze > requirement.txt
Then install all packages in once using:
pip install -r requirement.txt
For installing from zip simply use:
pip install *.zip
or specify the path directly:
pip install <path to .zip>
pip install ./my-archive.zip
Same applies for a tarball or any other format. It can be even a folder. However, it has to include a proper setup.py or other mechanism for pip to install it and pip has to support the packaging format (be it archive, networking protocol, version control system (git prefix), etc).
pip install ./my-folder
pip install ./
pip install .
pip install ..
etc
If, however, there is no setup.py present, you'll need to simply copy-paste the files somewhere where your project/module resides (or set PYTHONPATH or sys.path to that folder) to be able to import them. See this or this question for more.

Is there a way to install Flask globally

I am new to Python. Today I installed flask in C:Users\myName\FolderA using below commands and it worked fine. But when i try to create a structure C:Users\myName\FolderA\FolderB and create app.py in it, my VSCode says "ModuleNotFoundError: No module named 'flask'". Does this mean i need to install flask in Folder B too? Is there a way to install flask globally and make all folders under 'FolderA' access the libs?
Commands used to install Flask
C:Users\myName\FolderA\py -m venv env
C:Users\myName\FolderA\env\Scripts\activate
(env)c:Users\myName\FolderA\pip install flask
You are using a virtualenv. Everything installed inside a virtualenv resides inside that virtualenv (which is nice in fact: all your dependencies for that project only!).
If you want to install packages globally, run
pip install flask
without having run the activate script first (that activates your virtualenv).
PIP should install packages globally. You shouldn't have to reinstall flask everytime. Seems like something is wrong with your PIP. How did you install Python?
You could try updating PIP, which could fix it. Try running
python -m pip install –upgrade pip
in cmd.
Edit: This could also be an issue with Visual Studio Code. Try running the python code through CMD.

Install custom python package in virtualenv

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.

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

No module named changelist_ordering

I am trying to import changelist_ordering. So I have tried to install the package django-changelist-ordering. But I am getting the error:
No matching distribution found for changelist-ordering
Can anyone help me to solve this issues.
First of all install changelist-ordering by performing the following steps:
git clone https://github.com/SergeyKubrak/django-changelist-ordering
cd django-changelist-ordering
sudo python setup.py build
sudo python setup.py install
or you can install the package by running just one command (#jonrsharpe):
pip install git+https://github.com/SergeyKubrak/django-changelist-ordering
Now in your projects settings, include the app changelist_ordering in your INSTALLED_APPS
and then wherever you wanna use ChangeListOrdering import as
from changelist_ordering.admin import ChangeListOrdering
If this also does not work for you, check whether the module is installed in your virtual environment or not with
pip list | grep changelist-ordering
This should get you a result if changelist-ordering is present in your virtual environment else your Django application is trying to access the module which is not present in your virtual environment.

Categories