offline install for py2neo in ubuntu - python-2.7

I downloaded the .zip from the py2neo github and placed in the site-packages folder and ran
pip install py2neo
Everything looks like it's in the right place (I compared to windows setup and they both contain the same files in the same places) but when I run a .py I get:
ImportError: No module named batch *

It sounds like your paths aren't setup correctly. To install, I would recommend simply running the pip install py2neo line without first downloading the zip and allowing pip to pull py2neo from PyPI. Alternatively, if you are trying to avoid using a network connection from your server, run python setup.py install from within a copy of the GitHub repository.
Note: You will want to checkout the latest release branch from the GitHub repository before installing. At the time of writing, this is named release/1.6.4.

Related

Linux python django site-packages not recognized in envelope

I have tried to create envelope on my linux pop os system using miniconda. When I activate it, I can install packages using pip, but when I run my django instance it doesn't find the modules.
If I type which python is shows the miniconda path correctly. I can look in the site-packages folder and see the packages installed.
I've tried installing django-anymail and corsheaders and they are both not being found. It does find my locally installed apps.
If I use the command line and open python and then import, it does not recognize my modules installed in the virtual envelope either. I thought it was a problem with conda, so I also created an envelope using python's native method: python3 -m venv
I have the same problem with it finding pip install site-packages.
Is there a command I can run to show all available packages?
I hadn't realized I had aliased my python. Now it is working.

AWS Lambda (python2.7): Adding matplotlib as a layer

I am having trouble trying to add matplotlib as a layer to my Python 2.7 AWS Lambda function.
On the Lambda execution environment, I am trying to install the necessary libraries and create a layer as described here.
Things I've tried:
First, I pip installed matplotlib into a virtual environment and copied the contents of the site-packages under lib and lib64. When the lambda function is executed, I get a No module named pkg_resources exception. I also tried installing with the --target option to install all dependancies to the same folder. The result was the same.
I read here that it may be due to outdated setuptools package. When I did an update pip install --upgrade setuptools and then tried to install matplotlib I started getting the following exception:
pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
Finally I thought of installing matplotlib with
sudo yum install python-matplotlib
and then collect the required packages as described here. But this did not make matplotlib importable from within the python shell, so I guess it won't work as a Lambda layer.
Thanks for any help.
P.S: At AWS re:invent, exactly this was demoed but there are no details on the session :/
I encountered similar issues with other modules such as crypto and my own custom modules. I discovered the problem is really a lack of good documentation.
In my case, I was zipping all the dependencies up from the target directory, using the --target option, so all the dependency directories were at the top level of the zip file. That works fine for straight Lambda deployment, but when you want to use a layer, the layer is deployed in to the /opt folder of your Lambda container, so you need to create your zip file with a top-level directory named 'python' so that your dependencies can be located at /opt/python/.
mkdir python && cd python && pip install pyopenssl crypto --target . && cd .. && zip -r9 ./lambda_layer.zip python/
It does appear in the documentation but it is brief and VERY easy to miss. This page helped me: https://medium.com/#adhorn/getting-started-with-aws-lambda-layers-for-python-6e10b1f9a5d
Good luck!

Check if package available in python3

I have a project in Python2.7 and want to port it to Python3.6.
I want to build some kind of dependency tree where I can see which package is available in Python3.6. But don't know why how to check it without trying to install it to Python3.6 environment.
For example: boto-rsync is not available for Python3.6, but redis do.
And I need some advice where to start.
Use pip freeze in your both python2 and python3 environments and redirect them to a text files to see what all packages are installed.
Example:
pip freeze >> python2.txt
Click here for pip documentation.

confusion in deploying module's with django

Good day.
I'm a newbie to Django and I have a slight confusion:
When deploying my Django app, do I need to deploy it with all the Python 'come-with' modules, or the hosts already have them installed.
Also, I installed PIL for image manipulation. Would they also have it installed or i have to find a way to install it on their servers. Thanks in advance
do I need to deploy it with all the Python 'come-with' modules
Never do that. It might conflict with the dependencies on the server. Instead issue the following command to create a dependency file (requirements.txt).
pip freeze > requirements.txt (issue this command where manage.py is located)
On the server create a new virtual environment. Now copy django project to the server (you can do this using git clone or just plain old Filezilla). Activate virtual environment. Then change you current working directory to the where manage.py is located. to install all the dependencies issue the following command.
pip install -r requirements.txt
This will install the required dependencies on on server.

Is it possible to install a django package without pip?

I am trying to install django-dash to run one of the dashboard examples and see what it's like.
I am on Windows running Python 2.7 and Django 1.6.5. I know the usual approach is to download pip then install the package using pip. However, I am on a work computer with no administrative rights so I can't access my Internet Option Settings to find my proxy URL to follow the instructions below:
Proxy problems
If you work in an office, you might be behind a HTTP proxy. If so, set the environment variables http_proxy and https_proxy. Most Python applications (and other free software) respect these. Example syntax:
http://proxy_url:port
http://username:password#proxy_url:port
I had the same issue when trying to install Django but was able to get it to work by moving the django directory under Python27/Lib/site-packages. Is there something similar I can do with django-dash?
I also tried downloading the sources and running python setup.py install. I received the following error:
File "setup.py", line 3, in <module> from setuptools import setup, find_packages ImportError: No module named setuptools
Link to django-dash: http://django-dash.readthedocs.org/en/latest/
Yes, you can probably get the sources from The Python Package Index
Once you have them, uncompress the files and install them manually (this will depend on you OS).
On Linux systems:
python setup.py build
python setup.py install
Here's the full reference
EDIT : Note that when manually installing those packages, you must also install any missing dependencies, eg. setuptools in your case