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.
Related
I am familiar with using pip to install Python packages but there is no way to install it in the environment I am working in. We have to call the directory with python.exe to run any Python code. Therefore, it is impossible to use pip install because, since there is no python, there is no pip. How could we install packages without using pip or installing pip via the python.exe file? Here is an image of the error:
Packages like pip can be executed from the python executable using python.exe -m pip install openpyxl. If you don't have sufficient firewall permissions (as you mentioned high security) you may not be able to connect to the package servers, which you would need to discuss with admin.
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 have developed a tool that my team can use after running the setup.py script. The tool requires this library: https://github.com/c2nes/javalang
How can I make my python setup script install this library on their computer regardless of what OS they are on. They can't run my tool without that library (Some people are on windows, mac, and linux.)
pip can install projects on Github as a dependency too!
All you need to do is, in your requirements.txt, add a line like following:
..
git+https://github.com/c2nes/javalang.git
then install the dependency using:
$ pip install -r requirements.txt
What you are looking for exists on PyPI. Instead of git+https://.. line above, just say: javalang. Oh and BTW, unless they are running old versions of Python, they should already have pip installed. If they don't use your operating systems package manager or get-pip.py as you said.
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 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