Reputation: 7304
My python 2.7 was installed in /usr/local/lib.
If I type which python2.7
, I can have /usr/local/bin/python2.7
.
Then I set PYTHONPATH in ~/.bashrc as
export PYTHONPATH="/usr/local/bin/python2.7:$PYTHONPATH"
I like to install pip and virtual environment. Then tried as
sudo apt-get install python-pip python-dev python-virtualenv
When looking for python in /usr/lib
I found the following error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-dev is already the newest version.
python-pip is already the newest version.
python-virtualenv is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 362 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python2.7 (2.7.6-8ubuntu0.2) ...
python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7 (--configure):
subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
python2.7
E: Sub-process /usr/bin/dpkg returned an error code (1)
How can I set python path properly?
EDIT: My echo $PATH gave
/usr/local/bin:/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/bin/python2.7
echo $PYTHONPATH gave
/home/coie/Softwares/apollocaffe/python:/usr/local/bin/python2.7:
Upvotes: 0
Views: 15677
Reputation: 7304
I deleted all python installed in /usr/local
using >sudo rm -rf /usr/local/lib/python* or libpython*
. Those in bin and share folder are also cleaned.
Then since all program looked for python inside /usr
, the installation path is set to sudo ./configure --prefix = /usr
Upvotes: 1
Reputation: 16
type setenv PATH "$PATH:/usr/local/bin/python" and press Enter. or type export ATH="$PATH:/usr/local/bin/python" and press Enter.
Upvotes: 0
Reputation: 1186
According to https://askubuntu.com/a/250935/610294:
Try appending to PYTHONPATH instead of overwriting it completely.
Read: replace your line you added to bashrc with this:
export PYTHONPATH=$PYTHONPATH:/usr/local/bin/python2.7
Upvotes: 0