3

I'm trying to install phpsh on Ubuntu and I did everything on the install guide, but I am getting this error:

Starting php
Traceback (most recent call last):
 File "/usr/local/bin/phpsh", line 47, in <module>
   verbose=opts.verbose)
 File "/usr/local/lib/python2.7/dist-packages/phpsh/__init__.py", 
   line 503, in __init__
   self.php_open_and_check()
 File "/usr/local/lib/python2.7/dist-packages/phpsh/__init__.py", 
   line 641, in php_open_and_check
   self.php_open()
 File "/usr/local/lib/python2.7/dist-packages/phpsh/__init__.py", 
   line 698, in php_open
   preexec_fn=os.setsid)
 File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
   errread, errwrite)
 File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
   raise child_exception
OSError: [Errno 2] No such file or directory

Why am I getting these errors? How do I install phpsh on linux?

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335

4 Answers4

1

Open ~/.bashrc from the terminal using:

linux@terminal:vi ~/.bashrc

set PYTHONPATH and path in there:

export PYTHONPATH=~/lib/python2.6/site-packages 

//Put the above value as your site-packages directory location, 
//yours may have a different python version number.

Then add ~/bin to your PATH as well as per your directory structure.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Nishu Tayal
  • 20,106
  • 8
  • 49
  • 101
1

Walkthrough on installing phpsh on linux

The phpsh install guide at (http://www.phpsh.org/) site only gives you part of the details to get this up and running on linux.

The Gotchas:

  1. phpsh won't run on your system if you don't have PHP configured properly.
  2. phpsh won't run correctly if you don't have python configured properly.
  3. If gcc is not properly setup, then phpsh will not install correctly.
  4. You may need the python development headers for phpsh to work.

Here are all the specific steps I did to install phpsh on a Fedora 17 box

cd /home/el

sudo yum install php

sudo yum install php-posix

sudo yum install python

sudo yum install python-devel

git clone git://github.com/facebook/phpsh.git

cd /home/el/phpsh

sudo easy_install readline

python setup.py build

sudo python setup.py install

Open up your /home/el/.bashrc in an editor and add this line at the bottom:

export PYTHONPATH="/home/el/lib/python2.7/site-packages"

Make sure that the directory exists before you paste it in there. You may have to change the python2.7 to a different number to reflect your actual version. Restart the terminal.

Then, FINALLY, it runs as advertised:

el@defiant ~ $ phpsh
Starting php
php> echo "sweet lady freedom lets make out!  " . 1337;
sweet lady freedom lets make out!  1337
php> 

Then see my post to take a test drive of this tool: How to use the PHP interactive shell

Notes if you are adapting this to other flavors of Linux

You may have to use python-dev instead of python-devel.

Community
  • 1
  • 1
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
0

I was also getting this issue last day as I am a new learner of PHP. At last I figured out problems.

You must need to install php5-cli from apt-get before installing phpsh.

Also keep in mind that required python packages should also be installed. For that go to https://github.com/facebookarchive/phpsh.

I assume you already have python and you are using Ubuntu 14.04 or above. While installing the python packages you may get some other errors, as it may require you to install easy-install etc. But don't worry, you will get very verbose errors that will tell you exactly what to do.

Hope this solves your problem.

Vineet 'DEVIN' Dev
  • 1,183
  • 1
  • 10
  • 35
0

Sooooooooooooooooo I had this problem too.

phpsh is checking for php on your system & not finding it.

$ sudo apt-get install php5

This is partially a matter of poor logging. See the lines in the Traceback:

File "/usr/local/lib/python2.7/dist-packages/phpsh/__init__.py", line 641, in php_open_and_check self.php_open()

The kicker was that I tried sudo apt-get install php which now obviously didn't work, but for some reason I didn't keep at it!

Rob Truxal
  • 5,856
  • 4
  • 22
  • 39