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.

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

4 Comments

I can't. PermissionError [Errno 13]
Run everything without sudo (create new virtualenv from scratch). That's the purpose of virtualenv, to use it as normal user and have configurable private python environment.
You doing it in /usr directory? Why not in your home directory, where you have full permissions access?
Nothing works, I even tried installing it outside of a venv. Same error, all the time.
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?

4 Comments

I wouldn't know, I've never used pip inside of the shell before. Tell me a command.
@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?
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.
@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.
0

Thanks to this post.

Using the command:

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

Now it works like a charm.

Comments

Your Answer

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.