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.
Related
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.
I have a problem that comes from me following tutorials without really understanding what I'm doing. The root of the problem I think is the fact that I don't understand how the OS X filesystem works.
The problem is bigger than Python but it was when I started learning about Python that I realized how little I really understand. So in the beginning I started following tutorials which led me to use the easy_install command a lot and when a lot of tutorials recommended PIP I never got it running. So I have run a lot of commands and installed a lot of different packages.
As I have understood Lion comes with a python install. I have been using this a lot and from this I have installed various packages with easy_install. Is there any way to go back to default installation and begin from the very beginning? Is this something I want to do? If so why?
Is there any advantage of using a Python version I have installed with Homebrew? How can I see from where Python is run when I run the Python command?
When I do install something with either easy_install, homebrew, macports etc where do things actually end up?
Homebrew installs its software inside the /usr/local subdirectory on your Mac. OS X doesn't install anything there on its own; in fact, /usr/local is reserved for user-installed stuff. Since Homebrew never installs files outside /usr/local (and doesn't even have the ability to, unless you run brew using sudo - which is not recommended_) and OS X never installs files inside there, never the two shall mix.
easy_install and pip install files into system directories by default. That's why you have to run those commands with sudo to install packages with them.
I can't recommend virtualenv enough, regardless of which OS you're using. It installs a copy of Python, along with any packages or modules you want, inside a directory of your choosing. For example:
$ cd /tmp
$ virtualenv foo
New python executable in foo/bin/python
Installing setuptools............done.
Installing pip...............done.
$ cd foo
$ bin/pip install sqlalchemy
Downloading/unpacking sqlalchemy
Downloading SQLAlchemy-0.7.7.tar.gz (2.6Mb): 2.6Mb downloaded
Running setup.py egg_info for package sqlalchemy
[...]
Successfully installed sqlalchemy
Cleaning up...
[work, work, work]
[decide this was a bad idea]
$ cd /tmp; rm -rf foo
...and all traces of the project are now completely gone.
Use easy_install to install virtualenv into OS X itself - like you've done for those other packages - but then do all new development inside isolated directories that you can wipe clean at a moment's notice. This is pretty much the standard way of developing and deploying Python applications these days.
The advantage of using a Python installed via a package manager like Homebrew or MacPorts would be that this provides a simple way of removing the Python installation and reinstalling it. Also, you can install a more recent version than the one Mac OS X provides.
I recently installed python 2.7.2 on my Mac running OSX 10.6.8. Previously, I had version 2.6. I set my path in .bash_profile as follows:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH
so that when I run python it will refer to my new installation. It does.
I would also like to use pip with my new installation, but the problem is that I already have the current version of pip installed at
/usr/local/bin/pip.
I tried to re-install pip with:
easy_install pip
But, of course this does not put pip in the desired new directory
/usr/local/share/python/pip
but simply refers to the existing version in /usr/local/bin/pip.
Can someone tell me how to fix this?
I would like to then use pip to install NumPy and SciPy in the correct directory (I was having trouble getting the SciPy installation to work with my old version of python, hence the new install).
If you'd like, you can visit the website where I found instructions for installing python 2.7, creating/updating my .bash_profile, installing pip, and NumPy and SciPy. Might provide some insight, or I'm happy to give more details if needed. Thanks!
http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/#python
Install distribute as per the instructions at http://pypi.python.org/pypi/distribute .
Make sure you specify the full path to the python executable (/usr/local/share/python/python or smth in your case).
$ curl -O https://svn.apache.org/repos/asf/oodt/tools/oodtsite.publisher/trunk/distribute_setup.py
$ /usr/local/share/python/python distribute_setup.py
Then you should have /usr/local/share/python/easy_install.
After that, run:
$ /usr/local/share/python/easy_install pip
Then you should have /usr/local/share/python/pip.
Depending on the ordering of things in your PATH, either your old, or the newly installed pip is executed when you execute the pip command, so you either might have to adapt your PATH, or specify the full path to /usr/local/share/python/pip when installing eggs.
(shameless plug:
In any case, you might consider using virtualenv for installing packages into a "project" specific isolated environment, as opposed to installing them globally.)
I needed to uninstall brew's python.
Then, I was left with python v2.7.6
Next to install, pip I ran
sudo easy_install pip
installed fine and working
I had a similar issue, try this:
$ python -m pip install --upgrade --force-reinstall pip
This will force reinstall pip with whatever version of python you use including installing the binary.
A few days ago I had a friend who was starting Python Programming and needed help with the same issue: installing pip. There are debates over which one to choose between easy_install and pip and it seems everybody is heading the pip direction. Either way, installing either of them can be frustrating.
You can use this simple tutorial : installing pip package manager the easy way
Here are what you should keep in mind as you follow the above guide:
If you already have an older version installed, uninstall it or totally remove the python installation
Once that is cleared, download an install Python.
After that, download ez_setup.py file and save it to your desktop - easily accessible from the command line
Now run it from the command line and it will install easy_install for you after which,
You can use it to install pip.
Once again, you can do this or use the above link to find a simple step-by-step guide on how to get it installed on your computer.
Good luck.
Just so that people knew, ATM we can install PIP by downloading get-pip.py from the page with docs and run it like this:
c:\python27\python.exe get-pip.py
BTW, Python 3.4 comes with PIP pre-installed.
One of the command line options lets you choose where to install to.
--install-dir (-d) install package to DIR
So something like - # easy_install pip -d /usr/local/share/python
(Please correct me if I'm wrong.)
Just wanted to say that I found a way to get around my problem. I don't know that I can explain it perfectly, since I am not very good at understanding what I am doing with this stuff just yet! But, the problem seems to have been with my PATH. I removed the PATH that I posted in my original question, and then used easy_install pip. It went straight to python 2.7.2 (my new version) with no problem. I then successfully used pip to install NumPy and SciPy in the correct location, and they both work. Thanks to ErikAllik and FakeRainBrigand for taking the time to look into it!
I want to create a native Mac OS X package installer, the creation of the package is not really the problem, the real deal is the dependencies that have to get installed; I need to install Python, NumPy and Matplotlib (only if the required versions are not already installed).
I have heard really bad things about the Package Maker app, I've been reading a little and have already even found a nice tutorial although it is quite outdated. As a reference, here's Apple's reference guide.
I imagine I would have to use the uncompiled source provided from each of these three projects.
It would really help me to see the PackageMaker file that is used to create the official Python installer, if such file is available somewhere, please point me to it.
Anyway:
What would be the best way to do this? Is using a PackageMaker silly for this purpose? Any other literature that would help me?
Extra:
What would be the easiest way to test my installers?
I'm assuming that you want to install the packages that you mentioned because you are developing a Python application. Have you looked at PyInstaller? It "converts (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, Solaris and AIX", so you don't have to worry about what's installed on the target system.
And if you use PyInstaller, the "extra" would be easy. Simply copy the resulting executable to any other machine and test it out by executing it.
Something like /tmp/install.sh:
cd ~
curl -C - -O http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.tar.gz
tar -xzf virtualenv-1.7.tar.gz
cd ./virtualenv-1.7
python setup.py install
cd ~
rm virtualenv-1.7.tar.gz
rm -rd ./virtualenv-1.7
virtualenv myenvfolder
source myenvfolder/bin/activate
easy_install pip
pip install NumPy
pip install Matplotlib
And then:
chmod +x /tmp/install.sh;
/tmp/install.sh
Maybe you can use macports binary-packages or binary-archives?
and maybe fabric or puppet.
Puppet on OSX.
Macports is as simple as apt-get to use and takes care of all dependencies. By default macports installs to /opt/local so installs don't interfere with apple installs. Default is to compile from source. Some packages are big and have a lot of dependencies so compiling takes a lot of time and all the recourse on the machine. If you make a binary-archive you only have to compile ones pr machine arcithecture/osx-version. Then you only need to install macports and sett up a share with binary-archives. With fabric or puppet you can automate builds and distribution.
Then if you in the near future find out that you need pytable or numexpr it is as simple as: sudo port install py26-tables
and if other people need it to you can make binary-archive of it and put it on the share.
To install Python's latest version you can go here, and you can install NumPy and matplotlib directly in your terminal with these commands:
pip3 install matplotlib
pip3 install numpy
I just got easy_install downloaded but i'm having problems installing mechanize, should I be addressing site-packages at any point. In the first try below, i got an error. in the second try below, i got command not found which is wierd since I know for sure that it downloaded.
names-computer:~ names$ cd /Users/names/Desktop/
names-computer:~/Desktop names$ sh /Users/names/Desktop/mechanize-0.1.9-py2.5.egg
/Users/names/Desktop/mechanize-0.1.9-py2.5.egg: /Users/names/Desktop/mechanize-0.1.9-py2.5.egg: cannot execute binary file
names-computer:~/Desktop names$ easy_install mechanize
-bash: easy_install: command not found
apt-get install python-setuptools
This command will install easy_install on Ubuntu.
On OS X, Python interpreter instances are typically installed as so-called Framework builds which means that there is a bin directory within the framework which is typically (but not always) the installation destination for python scripts, such as easy_install. If you are not using the Apple-supplied python (in /usr/bin/) which has its own easy_install instance there, you should ensure that the framework bin directory of the desired python is on your shell search PATH and precedes /usr/bin. In particular, if you are using the python installed by the python.org installer, your PATH should look something like this:
$ echo $PATH
/Library/Frameworks/Python.framework/Versions/2.6/bin:/usr/bin:/bin
That ensures that the proper easy_install will be found first. If you are using a MacPorts python, it should look like this:
$ echo $PATH
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/usr/bin:/bin
EDIT: By the way, the egg that you downloaded appears to be for Python 2.5 and judging from a previous question, you may be wanting to use it with python 2.6. If you just use the command
$ easy_install mechanize
it should automatically download the proper egg, if available, or the source and do the necessary build and install steps.
You don't need to download mechanize to install it with easy_install. You just go:
/path/to/easy_install mechanize
Your problem is that you don't actually call easy_install.
bash: easy_install: command not found
That only works if easy_install is installed for the standard Python on your system. evidently you installed it for some other python. Figure out where you actually installed it, and call it with the path. Done!
mechanize-0.1.9-py2.5.egg is just a zipped file. Furthermore, you don't need to download the egg manually. easy_install will automatically pull down the code for you and install it.
You can install easy_install with ez_setup.py, a bootstrap script they provide.