0

I have been trying to install python packages and change the permissions of a folder using chmod. I can't remember which folder as it was just the one which the terminal said I did not have permissions for. I cannot even open it from x-term due to a python error(using python 2 print instead of 3?)

http://i.imgur.com/r3Nv31F.png

Since doing this I have been unable to open the gnome-terminal using the icon, the cursor becomes a laoding icon for a moment and then dissapears without opening the program.

I am also unable to use pip to install programs without using the program in sudo mode

Non-sudo pip3 execution error

Furthermore I cannot use the import command in python. Note that I have intalled scipy to my machine

Python import error

Does anyone know what I have done and how I can revert it?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
cdn
  • 654
  • 1
  • 8
  • 16

1 Answers1

0

wrt to the import failing, pip installs modules into the /site-packages directory of your python directory. So I think the issue is that pip installed it in a different python directory than the directory that the system is using when you type python3. I would highly recommend using virtualenv when installing packages - this way you can keep your python executable as well as the dependencies all in one place. However, some packages are required to be installed in the system's python directory. wrt pip requiring you to use sudo, how did you install pip? Usually I do sudo apt-get install python3-pip

Max Paymar
  • 588
  • 1
  • 7
  • 23
  • I installed pip as you said using sudo apt-get. The problem is that I cannot access packages which have been installed and used previously. I am unable to execute any Python code I have written which contains an import statement as I receive an ImportError. What I am wondering is how I can fix this so that I can import again. I appear to have a python 3.5 and python 3.6 folders in my /.local/lib folder. Is this normal? – cdn Feb 24 '17 at 15:47
  • 1
    You should check the /site-packages directory of your system python. If the packages weren't installed there, the imports will fail. It might be easier to just start fresh using virtualenv. – Max Paymar Feb 24 '17 at 15:59
  • 1
    Try ```import sys``` and then ```print('\n'.join(sys.path))``` to see where your site-packages directory is – Max Paymar Feb 24 '17 at 16:10
  • The result is `/usr/local/lib/python36.zip`, /usr/local/lib/python3.6, /usr/local/lib/python3.6, /usr/local/lib/python3.6/lib-dynload, /home/cdn/.ocal/lib/python3.6/site-packages, /usr/local/lib/python3.6/site-packages` – cdn Feb 24 '17 at 16:16
  • 1
    Looks good, now run ```ls -al``` on that site-packages folder to make sure scipy is there. If not, pip3 installed it in the wrong directory. – Max Paymar Feb 24 '17 at 16:25
  • You seem be right that there are no packages within the site-packages. The Python 3.5 dist-packages folder in the usr/local/lib/python3.5/ folder contains all of the them while the corresponding python3.6 folder contains none of them. How can I make my python use the dist-packages folder like it used it in the past? – cdn Feb 24 '17 at 16:30
  • The system will execute the first python it finds. So it is executing python 3.6 instead of 3.5. You can solve this multiple ways - the easiest way is to just remove python 3.6 – Max Paymar Feb 24 '17 at 16:40