Setting up tornado in mac - python

I'm new to using mac and tornado. I have installed easy_install and tried installing tornado but I am keep getting "Permission denied"
easy_install tornado
Searching for tornado
Best match: tornado 2.3
Processing tornado-2.3-py2.7.egg
Adding tornado 2.3 to easy-install.pth file
error: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/easy-install.pth: Permission denied
What is going wrong?

Try running it like this:
sudo easy_install tornado
When you are using stock python on OSX the easy_install command will install tornado system wide and it therefore needs admin rights. When using homebrew python (e.g. installed brew and python with "brew install python") then you can install python packages without having to do the sudo.
One word of advice: when working on a lot of python projects it's better to use virtualenv for installing python deps; that way you can have multiple isolated python environments AND you don't need the sudo.

You might want to try running that command as root if you want to install tornado system-wide or take a look at virtualenv for installing python packages in a sandboxed environment. Also, I recommend pythonbrew if you want to experiment with various versions of Python.

Related

Where does pip install its modules? What if using a virtualenv? Also getting an error setting up mod_wsgi

I am new to Python and there are some things which I am not able to apprehend. Questions may seem like very kiddish, so bear with me.
As you know, Ubuntu comes with an outdated Python version. I wished to use the latest python. But since it is recommended not to override the system's python, I installed virtualenv.
I installed pip first, using sudo apt-get install python-pip.
Then installed virtualenv, using sudo pip install virtualenv, and did all the configurations required to link it to the latest python.
The questions which I want to ask are-
Where does the command pip install <module> store the module in the system? I am asking this question because there is a section in this link, which says "Installation into Python". I was confused by this, thinking whether installing a python module is sensitive to which python version I am using. If it is so, then where does pip install the module if I am using virtualenv and otherwise.
I have manually installed Apache HTTP Server 2.4.23 using this link. While installing mod_wsgi using command sudo pip install mod_wsgi, I am getting this error
RuntimeError: The 'apxs' command appears not to be installed or is not
executable. Please check the list of prerequisites in the
documentation for this package and install any missing Apache httpd
server packages.
I searched for it and the solution is to install developer package of Apache. But the problem is that I am not able to find it anywhere on it's site. I want to install it manually. What to do? Also, If I install it through sudo apt-get install apache2-dev, Will there be any difference ?
Note: As mentioned on this link, I have already set the value of APXS environment variable to the location of apxs script, which is /usr/local/apache/bin/apxs.
Concerning 1., if I have well understood, you would like to have the last 2.7 or 3.5 Python version on your distribution. Actually, you can have multiple python distribution on your distribution. I would suggest you to have a look on conda/anaconda (https://www.continuum.io/downloads) : it is very powerful and i think it would better suit you than virtualenv: virtualenv would enable you to create a separate python environnement, but it would not install a newer version of Python.
Concerning 2, I am not an expert in Apache2, but I would have used apt-get instead of re-compiling apache. While compiling, you may need some dependancies to build the mod_wsgi module. So I think it is way more easy to use the pre-built packages from your ubuntu.

Installing txMYSQL on Python

I am trying to establish MYSQL connection with my twisted server script. I found out that txMYSQL is a good choice to use, I dowloaded the package out of Github and tried installing from the setup.py file, but it didn't work.
I tried inslalling txMYSQL by using easy_install txmysql but it dosen't appear to be found through this command since its not on pythons server.
How can I install txMYSQL ?
I am currently using python 2.7.8 on my Windows machine.
Try to install using pip and referencing Github repo. I tried here and worked well on a Ubuntu 12.04.4
pip install git+https://github.com/hybridlogic/txMySQL.git

installing modules in python - pip, distribute, nose, virtualenv

I'm aware that there are similar questions on SO. This one, for example: What's the proper way to install pip, virtualenv, and distribute for Python?
I'd like to install these modules as per my Learn Python the Hard Way tutorial: http://learnpythonthehardway.org/book/ex46.html
I managed (I think) to install pip by using sudo easy_install pip but when I then ran pydoc modules I could not see it. So I'm not even sure it's installed.
The answer above in question 4324558 is difficult for me to understand: what's a bootstrap, what's curl and why would I set up a virtual environment? Yes, as a learner I should try to pick up as much as I can but I don't want to first create the universe, I just want to get the task at hand done.
How do I install these modules? Is it as complicated as it sounds in the quoted answer? The top voted answer says "Install virtualenv into a bootstrap virtual environment. Use the that virtual environment to create more. Since virtualenv ships with pip and distribute, you get everything from one install."
I really don't get what all that means. Isn't there something about the "Zen" of python and a one true way to get things done? Or am I out of context here? What is "the right way" to install these modules?
I tried:
pip install virtualenv in the terminal and received the following output:
Wheel installs require setuptools >= 0.8 for dist-info support.
pip's wheel support requires setuptools >= 0.8 for dist-info support.
Storing debug log for failure in /Users/myname/.pip/pip.log
I'm using a Mac and python 2.7
To solve your issue,
Just install (or upgrade) the setuptools:
sudo easy_install -U setuptools
Then you can run again: pip install virtualenv
Try adding 'sudo' in your command as-
sudo pip install virtualenv
It worked for me.
Have a look at Python Development Environment on Mac OS X Mavericks 10.9.
I followed these steps as well when trying to get Python 2.7 and Python 3.3 installed on OS X. It doesn't tell you how to install nose and distribute, but you should have a working environment and you can pick up from there.
I did have a problem using virtualenv and pip with Python 3, the question and solutions is available here.

how to install additional python packages with pythonbrew

I am using pythonbrew to install 2.7.2 on my CentOS.
It has worked before but this time on a separate clean system I am running into an issue.
After installing pythonbrew (which I had to --force since it complained in make test about distutils) I switched to 2.7.2
When I run easy_install setuptools it tries to go system python (2.5). Since I am non superuser this ofcourse failed.
What am I missing here?
Finally I just ditched pythonbrew and did a multi install of python.
Thereafter I used bash and profile to switch between my python environments.

What version of python can I use with Twisted/Zope?

I noticed that Twisted has a dependency on Zope. I found that when I tried to install Zope, after running, ./configure it tells me I need to use python2.4 (not python 2.5+ which I would like to be using).
However, I have seen some tutorials and guides that suggested using python 2.5 for Twisted. So I'm just generally confused. Has anyone set this up and ran some of the twsited web examples that use zope? What version of python did you use? Was there an installation guide you followed somewhere?
Twisted doesn't have a dependency on full zope. It's just zope.interface, which is a small pure-python module packaged separately from all zope.
You can download the .tar.gz version and run the usual python setup.py install, that should work. Or if your operational system includes a package management system, you could check it for a easy-to-install package. Example, in debian/ubuntu you could do:
apt-get install python-zopeinterface
or even
apt-get install python-twisted
directly.
If you install twisted with pip install or easy_install it will download and install zope.install for you as well.

Categories

Resources