Installing Python package from source into virtualenv directory - python-2.7

Newbie programmer here. This is a variation of this question and this question.
I am running Python 2.7 on Windows 7, and using git bash shell. I am trying to install the numpy package into a virtualenv directory in my work directory. I cannot install it using the $pip install -r requirements.txt or the $pip install numpy commands because of errors caused by its dependencies. Here is a log file for this install failure.
Although I can install numpy directly by downloading the executable binary (.exe) from sourceforge, but it forced me to install it in the c:/Python27/Lib/site-packages directory. I need to install it in my virtualenv work directory, e.g. c:/Users/MyName/Projects/myproject/myvirtualenv.
I need help on how to download the necessary numpy files into a temp directory, and how to use pip or another tool install it into my virtualenv directory.
I researched that I can choose a target directory using the -t option in pip, e.g., "pip install numpy --target=c:/Users/MyName/Projects/myproject/myvirtualenv". But I still can't get over the dependencies errors, so pip doesn't work for me unless I can figure out how to download the numpy files (including all dependencies) into a directory and then install from there.
Thanks for your help!

Related

How to create a RPM which install python dependencies?

I have a python application that has flask dependency.
All I need is to create an RPM out of this application and with this RPM I should be able to install the dependencies to another machine.
Things I have tried,
Created a setup.py file,
setup(
name='sample-package',
version='1.0.0.0',
author="Niranj Rajasekaran",
author_email="nrajasekaran#test.com",
package_dir={'': 'src/py'},
namespace_packages=['main'],
packages=find_packages('src/py/'),
install_requires=['Flask']
)
Ran this command
python setup.py bdist_rpm
Got two RPMs in dist/, one is noarch and other is src
I tried to install noarch rpm using this
yum install {generated-file}.rpm
I am able to get sample-package-1.0.0.0.egg file in site-packages but not flask.
Two questions,
Is my approach correct?
If so what is something that I am missing?
bdist_rpm lacks of a lot of functionality and IMO is not very well maintained. E.g. pyp2rpm is much better for converting existing PyPI modules. But your module does not seem to be on PyPI, so you need to specify it to bdist_rpm manually because it cannot retrieve this information from setup.py.
Run:
python setup.py bdist_rpm --requires python-flask
This will produce an rpm file which requires the python-flask package. For more recent RHEL/Fedora it would be python3-flask.

How can I install python-Orange on ubuntu 12.10

sudo apt-get install python-Orange
or
sudo apt-get install python-orange
doesn't work
sudo python setup.py install
sudo python setup.py build
is not working as well.
Can anyone help??
Python has two tools for easy installation of all programs that are listed on the Python Package Index, also known as PyPi: These are easy_install and pip. Both retrieve very recent versions of Orange (and of any other package that is updating its PyPi entry regularly).
I installed Orange on Ubuntu 12.04 (LTS) with
pip install orange.
You will see lots of log lines indicating that Pip is downloading and compiling Orange for you. Simply wait. When pip is ready, fire up python and try to import orange. If that works, quit python and try the GUI with python /usr/local/lib/python2.7/dist-packages/Orange/OrangeCanvas/orngCanvas.pyw (you probably want to create a shell alias or bash script for that one :-)
NOTE: on 12.04 I needed to first upgrade 'distribute' itself with sudo easy_install -U distribute but this was clearly indicated by pip.
https://pypi.python.org/pypi/Orange/2.6/
You need to extract the dowloaded tarball on that page to a folder and then change directory to that folder. Then the sudo python setup.py... instructions will work (but you should 'build' the application before you 'install' it).
go to the given link "https://pypi.python.org/pypi/Orange/2.6/"
download the package and extract the file
install with given command
python setup.py build
python setup.py install
note:- during installation make sure that your net is working because it downloads required packages. Also it may ask for C++ or gcc compilers while installing and could be terminate just read the errors care fully and install requires packages from the synaptic package manage in ubuntu.

Trouble install PIP Windows

I have read posts on here but something doesn't seem to work. I am new to Python dev. I am running windows 7 64bit.
I am trying to install pip which I have downloaded and have easy_install in my c:\python27\scripts directory. When I use powershell and type
"python easy_install pip"
I get the error message:
"can't open file easy_install": [Errno 2] No such file or directory.
This seems odd as I can see the easy_install.exe is in that directory.
I have added c:\python27\scripts to my system PATH but, to be honest, I am not sure if this is right.
Could someone please help?
Thank you.
The selected answer dint fix it
This did:
python -m pip install -U pip
The best way to fix this is to compile easy_install yourself. First download the source code, and then compile it using python.
1 - Go here.
2 - Then extract the file, using 7-zip, or any software that can unzip a tar file. This is a tar.gz file, so after one extraction, it will give you the tar file, and then it will give you the actual directory and files for setup tools
3 - Go into the directory where you stored the contents of the extraction (using command prompt). For example, if you stored the directory on your desktop, you cd Desktop and then you go
cd dir_where_easy_install_is.
4 - Then run this command python setup.py install
That will install easy_install for you.
5 - Go back to your command line again, and then just type in easy_install pip, and that will install pip.
Then go ahead, and test it out, by installing django, just go into your command prompt, and enter this pip install django. After the download and the install, type in pip list, and see if django is in there. If it is, then pip has been successfully installed.
This worked running python from it's main dir against the easy_install.py in the extracted setuptools directory.
Then pip files should be in the Scripts dir.
Don't forget to run your CMD as administrator.

How can I tell whether/where python a virtualenv has been set up? (aka installing lxml on bitnami's djangostack)

I'm working on a django application on the bitnami djangostack. I want to use the lxml library, but I haven't been able to install it. Or rather, I haven't been able to install it where django can find it.
I've already used apt-get to install the libxml2, libxslt, and python-dev dependencies. Both of these commands report success*:
sudo pip install lxml
sudo apt-get install python-lxml
easy_install fails with a super-long error message that makes me think it can't find the dependencies. (I've run into this problem before.)
When I open up python or call python manage.py shell and try "import lxml", I get
"ImportError: No module named lxml"
As best I can tell, bitnami has set up a virtual environment for django, and pip and aptitude are installing lxml perfectly -- to the wrong python. Assuming that's all correct, how do I get lxml installed to the right one?
When you use apt-get install you are installing system libraries. BitNami DjangoStack is self-contained and independent. You could upgrade or remove your system libraries with apt-get and it would not be affected. Unfortunately lxml is not included in the stack nor libxslt which is a depency. We will include it in a future version however please find below the steps for manualing installing lxml on top of the python version included in BitNami DjangoStack.
You will need to use the system libraries for libxslt and libxml2. Be sure that you have them installed:
sudo apt-get install libxml2 libxml2-dev libxslt1.1 libxslt1-dev
Download lxml and uncompress it:
wget http://lxml.de/files/lxml-2.3.2.tgz
tar zxvf lxml-2.3.2.tgz
cd lxml-2.3.3
Load the BitNami environment:
. path_to_your_djangostack_installation/scripts/setenv.sh <-- notice the space between the dot and the path to the script.
which python <-- the output should be the python version from BitNami.
Install lxml specifying the path to your system libraries (notice that you should execute this command in the lxml directory):
python setup.py install --with-xslt-config=/usr/bin/xslt-config --with-xml2-config=/usr/bin/xml2-config
Now executing import lxml in the python console should work.
(This was already replied here)
There have been a couple of blog postings on installing this library on shared hosting. http://rhodesmill.org/brandon/2009/installing-lxml-on-webfaction/
How to install lxml for python without administative rights on linux?

How to reinstall PIL on mac OS X Snow Leopard

I have been for hours on this. I needed to get jpeglib and PIL reinstalled.
I installed jpeg lib from http://www.ijg.org/, please tell me if that's right.
I still have to reinstall PIL. I installed Fink, for apt-get, but still am not clear how to uninstall completely PIL before installing it.
And then installation, do i do apt-get install py-pil only? I see different instructions here and here. Which way should I go? I also can't figure out, does sudo python setup.py install reinstall python 2.6, or it just installs whichever thing i am in the directory of? However:
[petarpetrov#/Library/Python/2.6/site-packages/PIL]$ sudo python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
thanks in advance
Don't muck about with fink. That uses a completely separate install of Python and all its dependencies. It really won't help with your actual problem.
Secondly, you're trying to run things from inside site-packages - this is wrong. Go back to the directory where you downloaded PIL (or download it again, if you don't still have it) and run sudo python setup.py install.
And no, it won't reinstall Python - it uses python to run the setup of the directory you're in.