Error when installing Django with pip - django

I am trying to install Django 1.8.0 on my Ubuntu like this:
pip install Django==1.8.9
And this is the error Im getting:
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/Django-1.8.7.dist-info'
Any idea what's the problem?

Run in shell:
sudo pip install Django==1.8.9
But, as said in comments, you better use virtualenv with or without virtualenvwrapper. If you have python 3.3+ the recommended approach is to use pyvenv (with or without virtualenvwrapper) instead of virtualenv.

Related

permission denied : while installing django in windows

permission denied
I was trying to install Django using pip3 install django==2.0.2 on windows.
But I am getting "permission denied " error message.
But pip3 install django==2.0.2 --user is working, but "Django-admin" command is not being recognized.
Please help me out.
C:\Users\Hima>pip3 install django==2.0.2
fd = os.open(file, os.O_RDWR | os.O_CREAT | os.O_EXCL)
PermissionError: [Errno 13] Permission denied: 'c:\\program files (x86)\\python38-32\\Lib\\site-packages\\accesstest_deleteme_fishfingers_custard_gijd2m'
Your installation with --user argument works because --user makes pip install packages in your home directory instead of system directory, which doesn't require any special privileges. You have not enough privileges to install it to system dir.
If you are sure of what you are doing - run pip with administrative privileges but do remember that anyone can uploade libraries to pip and thus there is a risk of running malicious code.
Better way to go is to use a virtual environment

How can I fix pip install error: 'EnvironmentError: [Errno 42] Illegal byte sequence'?

I am trying to download kivy module using pip.
When I run the pip install command, I got an error: Could not install packages due to an EnvironmentError: [Errno 42] Illegal byte sequence.
I already re-installed python, I am running as an administrator and I also tried to download via the wheel file. All of the above causes the same environment error.
There seems to be a bug in pip https://github.com/pypa/pip/issues/5665.
The current workaround is to run the command in silent mode
pip install kivy -q
or
pip install kivy --progress-bar=off
pip install kivy -q
(Not a solution, a workaround - This is a bug in displaying progress bar in pip. Above command hides the progress bar while installing)
Solution based on this.

Superset ImportError: No module named psycopg2

I am getting the following error when trying to connect to a postgres db in superset
ImportError: No module named psycopg2
I have install psycopg2 with pip and restarted the superset by still getting the same error. any idea?
If you are running superset inside a virtualenv, try to install psycopg2 at system level.
Also, install psycopg2-binary package.
As stated above, you may have installed superset in a virtual environment as suggested in the install guide (https://superset.incubator.apache.org/installation.html#python-virtualenv)
A good indicator is to search for where you installed superset and if it's in a folder venv, it's likely in the virutal environment.
You need to ensure that the python packages are installed in your virtual environment as well.  Installing on your local computer will not work.
Go to where you installed superset (in my case /Applications/venv/), and activate the venv: 
. venv/bin/activate
Install your packages
pip install psycopg2

Can't find any modules in Django project

I've been following a Django tutorial and initially created virtualenv and a requirements file in it. Project was halfway and in working state. Today I activated virtualenv successfully and tried python manage.py runserver to get error
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
I realized it's not finding Django and just to be sure checked my requirements.txt file (which confirmed right Django version). Tried to reinstall it from the file using pip3 install -r requirements.txt (tried using just pip too) to get another error --
ModuleNotFoundError: No module named 'pip'
It seems the environment is unable to find any of the modules. I tried to reinstall pip also just to be sure, but then it couldn't find apt-get command.
OS: Mac OSX El Capitan 10.11.6
Python: 3.6.2
Django: 1.10.3 (in requirements file)
Try running python -m ensurepip (or python3 -m ensurepip) to see if pip is already installed:
In most cases, end users of Python shouldn’t need to invoke this module directly (as pip should be bootstrapped by default), but it may be needed if installing pip was skipped when installing Python (or when creating a virtual environment) or after explicitly uninstalling pip.

Unable to get these to cooperate: mysql-python + virtualenv + percona + centos6

I've gone through many threads related to installing mysql-python in a virtualenv, including those specific to users of Percona. None have solved my problem thus far.
With Percona, it is normal to get a long error on pip install MySQL-python in the virtualenv that ultimately says EnvironmentError: mysql_config not found. One method to remedy this is yum install mysql-devel, which I've done. I can actually get mysql-python to install properly outside of the virtualenv via yum.
I'm getting the error in the virtualenv only - it uses Python 2.7.9, wheareas 2.6.6 is what comes with Centos.
Also, with MySQL-python installed via yum it will import to the OS's python interpreter, but will not import into the virtualenv's python interpreter.
To clarify, I only installed mysql-python via yum to see whether or not it would work that way. I would prefer it be by pip, in the environment only.
What am I missing here? As far as I'm aware it should work - considering it will work outside of virtualenv.
Found the solution!
I think it was improper of my to install mysql-devel in the first place, so I went ahead and uninstalled it.
Instead, I used a packaged supplied by Percona - Percona-Server-devel-55
yum install Percona-Server-devel-55 and the problem is solved!