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.
Related
I have pip3, installed via the yum install of python3-pip.
I've done a pip3 global install of some modules I need, but python3 can't find them to import. After a little investigation I see that pip3 installed the modules to /usrlib/python3.6/site-packages/pip/_vendor/
The problem is that python3 doesn't seem to know to look at pip/_vendor, it only finds modules directly installed under site-package. If I just copy the modules from .../site-package/pip/_vendor to .../site-package everything works fine.
The issue doesn't appear to be related to file permissions or ability to read the modules.
I'm wondering how I configure either pip to install directly to site-package or python3 to understand how to look in the pip/_vendor location.
I'm configuring this all with ansible and would like as module an option as possible. For instance I could manually use an argument to tell pip3 to install to the folder I want, but I don't want to hardcode the exact site-package directory if I don't have to.
I recommend starting over with pip by downloading and running get-pip.py. This will not only install the latest version of pip, but it will also install packages to a Python-readable location (the version of Python you use to run get-pip.py).
As an aside, I would avoid installing packages system-wide unless there is a specific need for them. At the very least, you should be installing them as a regular user, and even better you should be using a virtualenv.
I use Atom to create a Python Script, my script use some packages like requests, sendgrid and others..
To install this packages I use:
pip3 install requests
But this command install this package somewhere in windows, but my requirement is to package my script and this libraries to use them as an aws lambda.
My question: is there any way in Atom to package this with my script, or is there any command line to put this libraries in the same folder as my script and then I zip the folder? or what is the correct way to solve this issue?
I find the solution in the aws documentation:
I just used:
$ pip install --target 'C:\path-to-project\my-project' requests
I'm guessing you want to package this so you can use the package in the lambda function. This won't work if you've got a windows, because the Lambda function runs on a linux container (or sometimes it might work for pure python packages).
A more sustainable option is to use something like Klayers, you can set the preferred package as a layer for your function and it'll work.
Another option is to use the python serverless requirements package for the serverless framework. https://www.serverless.com/plugins/serverless-python-requirements/
You should be able to use:
pip install --ignore-installed --install-option="--prefix=$YOUR-PATH" requests
The --ignore-installed flag is used to install other dependencies as well, even if those are already installed in the python packages folder.
Here's my problem,
I have a shared hosting (GoDaddy Linux Hosting package) account and I'd like to create .py file to do some scraping for me. To do this I need the scrapy module (scrapy.org). Because of the shared account I can't install new modules so I installed VirtualEnv and created a new virtual env. that has pip, wheel, etc. preinstalled.
Running pip install scrapydoes NOT complete successfully because scrapy has lot of dependencies like libxml2 and it also needs python-dev tools. If I had access to 'sudo apt-get ...' this would be easy but I dont'. I can only use pip and easy_install.
So How do I install the python dev tool? And how do I install the dependencies? Is this even possible?
Cheers
You can install all the dependencies by activating the python virtual environment first.
Step 1 :
On Linux :
env/bin/activate
On Windows :
env\Scripts\activate
Step 2:
pip install lxml
I just tried and it worked for me. Please find screen shot attached.
It's not possible to do what I wanted to do on the GoDaddy plan I had.
I had some of the same issues. I found this and modified to pip3.7 install lxml==3.4.2. I was able to install successfully.
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
I am new to python just a few weeks back i started using python(Classic Noob-Disclaimer)
Now whenever i install a module by copying the unzipped folder in site-packages under Lib and running the source install by using "c:\python27\lib\site-packages\tweepy-1.2\setup.py install" in command prompt it installs without any errors.
But now when i make a python script (*.py)
and store it on the desktop it wont work
and it gives out an error "No module found"
but when i store it in the same folder as the source it works perfectly.
also if i open the IDLE GUI it also returns the same error.
But this doesnt happen with the win32com module which i use for TTS.
I missing something..but i cudnt find the answer to it.
Plz help me!
i need to use many of these modules..they work great differently but not together as the modules are always missing!
Copying an unzipped folder to site-packages does not install a Python package.
To install manually, unzip the package to a temporary directory, then run:
python setup.py install
in this directory, after that you can remove the directory.
To download and install a pure Python package automatically, run:
pip install tweepy
if you have pip installed.
The simplest way to install Python packages that have C extensions is to use binary installers (*.exe, *.msi files).
To avoid all this use VirtualEnv
Virtualenv is a tool to create isolated Python environments.
The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages (or whatever your platform's standard location is), it's easy to end up in a situation where you unintentionally upgrade an application that shouldn't be upgraded.
Or more generally, what if you want to install an application and leave it be? If an application works, any change in its libraries or the versions of those libraries can break the application.
Also, what if you can't install packages into the global site-packages directory? For instance, on a shared host.
The easiest way to install python packages is by using pip. First you need to install pip as explained here if you use windows. Then you can query some packages, from command line, for example
> pip search twitter
Then to install certain packages, just use pip something like this:
> pip install tweepy