0

Basically, I set up a Virtual Box with Ubuntu Server (stable). Installed python 3.5.1, meaning I have 2.7, 3.4.3 and now 3.5.1. I installed virtualenv and had a lot of problems with telling it which interpreter to use, again this is due to my lack of experience. I eventually set it up using:

sudo virtualenv -p /usr/bin/python3.5 fmenv

Now, when I activate it, (after hours of changing things), if I type in:

python

I get a 3.5.1 interpreter, good. If I do:

pip -V

I get:

pip 7.1.2 from /usr/.../fmenv/.../site-packages

also good. By the way, virtualenv is 13.1.2

The problem is that when I run:

sudo python -m pip install django

or simply just:

sudo pip install django

I get a SyntaxError: invalid syntax, (download is good, by the way).

Now I was thinking, maybe with:

sudo python3.5 -m pip install django

it can work, but it says no module named pip, so I tried to manually specify it, that didn't work also. Anyway, thank you in advance for any help.

Filip Markoski
  • 333
  • 3
  • 19

3 Answers3

1

Using sudo switches to root and it has no knowledge of your virtualenv. Just run it without sudo. It is not needed with virtualenv.

0
SyntaxError: invalid syntax

Is an error you get from the python prompt not from a system shell. What's the error message you're getting when you run pip from the shell?

  • I wouldn't know, I've never used pip inside of the shell before. Tell me a command. – Filip Markoski Jan 18 '16 at 07:10
  • @AquaSolid pip install ... is command you run from a unix shell or DOS shell. These system shells is where you typed `python` earlier in order to get into the python shell. My point is that you get `SyntaxError` from the python shell not the system shells. I understand you're getting an error when you're running it from the system shell. What is it? – Nabil Khoury Jan 18 '16 at 07:24
  • Considering that my venv is active with pip install django I just get a PermissionError, sudo pip install django works, but when I do pip freeze, django is not in the list. But, It's fine, since it works with sudo then it's okay, I can live with that, I can live without a venv. – Filip Markoski Jan 18 '16 at 07:36
  • @AquaSolid Cool. Although you'll have to run `sudo python` every time you want to run a Django app, which probably gets annoying with time. As ESYSCODER said, the only way to avoid this is to make sure you re-installed whatever packages are giving you permission errors without `sudo` if possible. I've been through that process before. It's annoying but better than having to run everything as `root` every time you run a django app. – Nabil Khoury Jan 18 '16 at 08:05
0

Thanks to this post.

Using the command:

sudo chown -R aquasolid:aquasolid /usr/virtu/fmenv/

Now it works like a charm.

Community
  • 1
  • 1
Filip Markoski
  • 333
  • 3
  • 19