Having trouble with setup.py - python

I've been using python for a while but I can't remember how I used to install modules, I haven't needed to in forever. I recently reinstalled ubuntu so now I need to.
Firstly, I try to run setup.py and get this:
nicholas#nicholas-K53E:~$ python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
I tried using synaptic to install BeautifulSoup but it didn't work either and python tells me there's no modules named that.
Some forums said that it had to do with being in the wrong working directory so I cd'd into my Python26 folder and tried to run python ./setup.py install from there and it still didn't work. I'm not sure what the deal is.
Any guidance?

sudo apt-get install python-setuptools
OR
sudo aptitude install python-setuptools
Then just run:
sudo easy_install <module>
e.g.
sudo easy_install BeautifulSoup

sudo aptitude install python-beautifulsoup should do that for you. Synaptic is alright, but I prefer aptitude for many reasons (CLI is one of them obviously). Most of the modules you want should be available through your package manager, and beautifulsoup should definitely be. If that command does not work for you, there are other issues you need to look at.
You should definitely be able to use easy_install for more popular packages and well, and as far as utilizing setup.py you need to be in a directory actually containing it. What does ls | grep setup.py return for you when you are in the proper working directory? setup.py typically comes with a downloaded package, so make sure you are actually in the folder containing that package.

See other answers that recommend using the package manager that comes with Ubuntu (aptitude). This is the easiest way to do it.
However, to answer your specific question, to install a package based on the Distutils you need to download the package, extract it, and then run the setup.py script.
As an example for BeautifulSoup:
Download the package from Beautiful Soup 4.1.3 (at time of writing get the beautifulsoup4-4.1.3.tar.gz tarball).
wget http://www.crummy.com/software/BeautifulSoup/bs4/download/beautifulsoup4-4.1.3.tar.gz
tar xvfz beautifulsoup4-4.1.3.tar.gz
cd beautifulsoup4-4.1.3
sudo python setup.py install

Sudo command will not work in Windows.
If you have something to install don't use Sudo, instead directly install your file:
for ex: If you sudo python3 setup.py install
then windows users can just type setup.py install

Are you using windows? if so, replace the python with C:\python39\python.exe and type in the rest of the command.

Related

How to remove a python module and its dependencies that is installed a specific directory?

When I install a python module at a specific directory. Is there a command to remove the module and its dependencies? I know that I can remove it by deleting the directory.
pip install requests -t ./libs
You can try
PYTHONPATH=libs pip uninstall -y requests
It's not a complete solutions — when I did an experiment pip tried to uninstall a non-existing scripts from /usr/bin (the scripts were actually in ./lib/bin).
So it seems rm -rf ./libs is the only real solution.

running sudo pip install times out

I'm having an issue when trying to run sudo pip install ... as it timesout when ever I try to install a package that way. I'm behind a proxy (OS is RHEL7) and I setup the proxy by running:
export http_proxy=http://proxy:8099
export https_proxy=http://proxy:8099
if I do a pip install ..., that downloads but can't install because I'm not running as sudo. If I do sudo pip install ..., the Collecting ... part keeps giving me a network unreachable error.
Try downloading the *.whl file and install the package passing the filename as parameter to pip. For example, the following line is trying to install BeautifulSoup.
python -m pip install beautifulsoup4-4.5.3-py2-none-any.whl
Also, you may download the compressed file, extract it and run the setup.py file inside of that folder.
tar -xzvf beautifulsoup4-4.5.3.tar.gz
cd beautifulsoup4-4.5.3
python setup.py install
Wanted this answer to be a comment, but still. You have:
export https_proxy=http://proxy:8099
which is using http, but it should be https actually. Try editing this line.
In addition to what the others have posted, I found this link. It seems that there is a known problem with pip and proxies. You also may have to use the --proxy=<proxy address> flag with your pip command.

Straight and simple answer: installing py2app

I have been searching all day how to install py2app. I have downloaded the folder but I don't know how to actually install the application.
Also, if anyone could give me an easy way of using py2app that would be great!
Which Python version are you using?
Assuming you use Mac OS X version, first you need to install pip.
For that google: how to install python pip?
This is really easy.
And after that issue in your terminal
$ sudo pip install -U py2app
if you already have the source package downloaded, it has a setup.py file in it's top-level directory. To install, just invoke it like this:
python setup.py install
also, you could read the installation instructions:
https://pythonhosted.org/py2app/install.html

wget is not recognized as a command even though it is installed

I know I am doing something really stupid here but I have tried the things I can think of.
Here is the relevant portion of my session:
$ wget http://pjmedia.com/instapundit/
-bash: wget: command not found
$ cd ..
$ pip install wget
Requirement already satisfied (use --upgrade to upgrade): wget in
./anaconda/lib/python2.7/site-packages
$
I have restarted my computer and that does not help. I am using Mac OX X with the El Capitan system installed. Does this have something to do with the PATH variable? I found something on the internet that seemed similar to my problem with another program on the Windows system, but I have found nothing for the Mac OS. I tried installing it from my root directory but the system won't let pip install it because it is already installed. Can anyone point me in the right direction?
EDIT: I would like to thank Max, Bill and kenorb. I have learned more here for free in 10 minutes than I have in a week at some commercial sites. Is there some way to mark my question as answered so that people don't have to keep wasting their time reading my question?
Use some OS X package manager like Homebrew (brew) or MacPorts, as pip is used for python modules:
brew install wget
Wget the shell command is probably easiest to get on OSX by using Homebrew, and then running brew install wget.
What you've got there is the python module wget, which follows the same name. It can be used by running python -m wget [options] <URL>, where your options are to supply an output file name with -o. You could always alias this to wget in your .bashrc!
make sure that wget is downloaded in your windows, you can download it as exe file then copy and paste it to your system32 path as follows:
https://eternallybored.org/misc/wget/
c/windows/system32/wget
pip installs Python modules. In some cases that includes installing a command-line utility as well, but as far as I can tell, with this module that is not the case. So unless you are going to write a Python script that uses the wget module and fetches the file, this won't do what you want.
The easiest way to install wget is with homebrew, but that does require a small bit of setup. The setup is very worth it, as you can install nearly any "unix" utility from brew, including servers such as nginx or postgresql.
Once homebrew is set up, simply brew install wget and you should be set.

Breaking 'pip install' to smaller steps, so I can edit the package before it is installed

My familiarity with pip ends up with the ability to do: 'pip install', 'pip uninstall', and 'pip list' - with the name of the package I want to install as the single argument.
This limited knowledge carried me so far, to the extent I'm able to install most of the simple packages, and sometime, when I'm luck, I'm even able to install packages that requires compilation. This is all magic for me.
I'm now facing a situation where I need to do a little bit of editing to the C file (side note: this seems to be a known workaround for the 'netifaces' package - which everyone seems to be in peace with. By itself this is an amazing phenomena).
So I would like to break the installation into smaller steps:
Download the egg file (I've figured out this one: pip install --download).
Unzip or otherwise unpackage the package file, to the point I can edit individual
Do my custom modification.
Do the build
Do the installation.
Other than step #1, I don't know how to proceed.
Modern pip (Since 1.10)
Use pip download:
pip download mypackage
pip 1.5 - 1.9
Use pip install -d
pip install -d . --allow-external netifaces --allow-unverified netifaces netifaces
tar xzf netifaces-0.8.tar.gz # Unpack the downloaded file.
cd netifaces-0.8
Now do your modifications and continue:
pip install .
Old pip (Before 1.5)
Install the package with --no-install option; with --no-install option, pip downloads and unpacks all packages, but does not actually install the package.
pip install --no-install netifaces
Change to the build directory. If you don't know where is the build directory, issue above command again, then it display the location.
cd /tmp/pip_build_falsetru/netifaces
Do the custom modification.
Install the package using pip install . (add --no-clean option if you want keep the build directory) or python setup.py install.
sudo pip install --no-clean .
First, download the source to 0.8 from the author's home page (there's no direct download link from PyPI, for some reason). Go to the directory where you downloaded it and unzip it:
tar zxvf netifaces-0.8.tar.gz
Enter the netifaces-0.8/ directory and edit netifaces.c with your favorite editor. Save the file. Then, build the module:
python setup.py build
and install it:
sudo python setup.py install
To test, first leave the directory, then start your python interpreter and import netifaces to see if it works.
Good luck!
Download your selected package, extract the files,edit what you want. Then, open the directory with your terminal\cmd and run:
python setup.py install
Depending on your os you might need to add a little sudo to the beginning of this command (if you intend to install globally on a Unix machine)
You could just download the source from pypi, edit it and use setup.py buid, setup.py install

Categories