1

I installed python3.5.2 from my home directory from a tar. (I remember using an atlinstall command)

Then, I installed django using pip3, by doing sudo -H pip3 install django, and the installation was successful.

I also installed numpy, scipy, some other modules.

All these modules are accessible when I am using python3.5 as the command from the command line, but I am not able to import these modules when I call python3.

And, all the third party software is also using this python3, as a result I am not able to use any GUI to import any of the modules mentioned.

My question is, how I can get the other python3 to point to the same thing as python3.5 which has all the modules installed.

salman@Skynet ~]$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>> exit()
[salman@Skynet ~]$ python3.5
Python 3.5.2 (default, Nov 30 2016, 11:30:08)   
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> 

It works when python3.5 is used.

Edit: Requested outputs

which python3 python3.5:

/usr/bin/python3
/usr/local/bin/python3.5

env | grep -i python; for p in $(ls /usr{,/local}/bin/python3*); do echo -- $(ls -l $p); $p -c "import sys; print(sys.path)"; done

-- lrwxrwxrwx 1 root root 9 Mar 23 2016 /usr/bin/python3 -> python3.5
    ['', '/usr/lib/python35.zip', '/usr/lib/python3.5',  '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-  dynload', '/usr/local/lib/python3.5/dist-packages',  '/usr/lib/python3/dist-packages']
-- -rwxr-xr-x 2 root root 4460336 Nov 18 01:23 /usr/bin/python3.5
    ['', '/usr/lib/python35.zip', '/usr/lib/python3.5',  '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib- dynload', '/usr/local/lib/python3.5/dist-packages',   '/usr/lib/python3/dist-packages']
-- -rwxr-xr-x 2 root root 4460336 Nov 18 01:23 /usr/bin/python3.5m
    ['', '/usr/lib/python35.zip', '/usr/lib/python3.5',  '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib- dynload', '/usr/local/lib/python3.5/dist-packages',   '/usr/lib/python3/dist-packages']
-- lrwxrwxrwx 1 root root 10 Mar 23 2016 /usr/bin/python3m ->  python3.5m
    ['', '/usr/lib/python35.zip', '/usr/lib/python3.5',  '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib- dynload', '/usr/local/lib/python3.5/dist-packages',  '/usr/lib/python3/dist-packages']
-- -rwxr-xr-x 2 root root 12170760 Nov 30 11:30   /usr/local/bin/python3.5
    ['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5',  '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib- dynload', '/usr/local/lib/python3.5/site-packages']
-- -rwxr-xr-x 2 root root 12170760 Nov 30 11:30  /usr/local/bin/python3.5m
    ['', '/usr/local/lib/python35.zip', '/usr/local/lib/python3.5',  '/usr/local/lib/python3.5/plat-linux', '/usr/local/lib/python3.5/lib- dynload', '/usr/local/lib/python3.5/site-packages']
-- -rwxr-xr-x 1 root root 3080 Nov 30 11:31  /usr/local/bin/python3.5m-config
Usage: /usr/local/bin/python3.5m-config --prefix|--exec-prefix|--  includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--    configdir

Also, how can I delete the python3.5 from the /usr/local/bin without harming the python3 in /usr/bin?

Thank you everyone for reading the question and answering.

Zanna
  • 72,312
Skynet094
  • 121

1 Answers1

1

One solution -- although to be considered carefully -- is to have python3 point to the python3.5 which works correctly:

sudo mv /usr/bin/python3 /usr/bin/python3_backup
sudo ln -s /usr/local/bin/python3.5 /usr/bin/python3 

Update: Other method

My first answer was in the case you were sure you needed the python3.5 in /usr/local/bin. If that's not the case and you want to keep the system python 3 while adding modules from your /usr/local python3.5, you can simply update your PYTHON_PATH variable as follows in your bashrc (as according to the outputs you provided):

export PYTHONPATH=${PYTHONPATH}:/usr/local/lib/python3.5:/usr/local/lib/python3.5/plat-linux:/usr/local/lib/python3.5/site-packages
Zanna
  • 72,312
michael
  • 254