0

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:
ZF007
3,7399 gold badges33 silver badges52 bronze badges
asked Nov 8, 2016 at 8:33
2
  • Just verifying, you did mean ~/.bashrc and not ~/bashrc, right? Commented Nov 8, 2016 at 8:35
  • Sorry ~/.bashrc Commented Nov 8, 2016 at 8:36

3 Answers 3

1

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

answered Nov 9, 2016 at 1:44
Sign up to request clarification or add additional context in comments.

Comments

0

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

answered Nov 8, 2016 at 8:39

2 Comments

Yes I put the path behind
In the comment I linked, that thread also mentions about the script folder. Have you tried that? (export PYTHONPATH=$PYTHONPATH:/usr/local/bin/python2.7/Scripts)
0

type setenv PATH "$PATH:/usr/local/bin/python" and press Enter. or type export ATH="$PATH:/usr/local/bin/python" and press Enter.

answered Nov 8, 2016 at 8:42

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.