As root I install lots python modules by pip, which work fine.
python import cmd
Create a new user by adduser new with no flags.
I was su - new to this account.
After that, Even pip is error:
Traceback (most recent call last):
File "/bin/pip", line 7, in
from pip import main
ImportError: No module named pip
I think the problem is lost path reference.
which my modules is under
/usr/lib/python2.7/site-packages
The os is Centos7, I think i need a answer for how to permantly added the module path.
Thanks.
Related
I installed spyder on my ubuntu system From which django is not working. The error it is showing when i ran the server the error showing is is
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
import django
ModuleNotFoundError: No module named 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 17, in <module>
"Couldn't import Django. Are you sure it's installed and "
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 need both spyder for OpenCV and also Django. can anyone help
It is working after doing
python3 -m pip install django
thank u mr sahil
The error means that the Django is missing from your system, if you have installed the dependencies in your virtualenv you will need to activate that, or you can just do
pip install django --user
If you have a virtualenv do this,
Linux
source path/to/venv/bin/activate
Windows
path/to/venv/bin/activate
First create a virtual environment, using the following command
python3 -m virtualenv venv
If you get an error saying something similar to this, Virtualenv module not found, you will need to install virtualenv using pip by the following command.
pip3 install virtualenv
Then use the aforementioned command to create the virtual environment.
To activate it just use
source venv/bin/activate
This will activate the virtual environment. Now install Django on it.
pip install django
You don't need to specify a pip version (say pip3) because the virtual environment is created in python3 so pip defaults to pip3 itself.
Now finally run your server
python manage.py runserver localhost:8080
I'm trying to create a new environment and install various 3rd party packages on an Ubuntu machine. After having to install condo (for a matplotlib installation) and gdal, the pip function no longer works. Instead I receive:
Traceback (most recent call last):
File "/media/imagery/ENVIRONMENTS/Project_1/bin/pip", line 7, in <module>
from pip._internal import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 14, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/usr/lib/python2.7/dist-packages/pip/utils/__init__.py", line 30, in <module>
from pip._vendor.retrying import retry
ImportError: No module named retrying
I've called pip both in and outside my environment, and still observe the same issue. Also I've tried a pip install --upgrade pip and still retrieve the same Traceback. Any ideas how to resolve this?
As a cheap workaround, export PYTHONPATH=" " seemed to work for now in order to install other packages, but as soon as I need the gdal package, I have to then set PYTHONPATH again.
I had a similar exception and could manage to repair it.
In my case I upgraded Ubuntu 16.04 to Ubuntu 18.04.
I had to re-create the virtualenv. Depending on your choice:
virtualenv .
Or
virtualenv --system-site-packages .
creating my first module in django,
I am using mac Tried steps:
1.installed python 3.6.+ version,
2.cloned git project
3.setup local env,
to create a module,
trying with command
env=dev python3 manage.py startapp supriya_module_inflow;
getting error in console :
Environment Selected :dev
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 24, in <module>
import MySQLdb as Database
ModuleNotFoundError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_from_command_line(sys.argv)......
...
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
MySQLdb does not support Python 3. You'll want to pick one of the other MySQL drivers.
At the time of writing, the latest release of MySQLdb (1.2.5) doesn’t support Python 3. In order to use MySQLdb under Python 3, you’ll have to install mysqlclient instead.
Here is How to install mysqlclient in Python using pip so as to be able to import MySQLdb in Django 3.1 when running Python 3.8.5..
The error message indicates that there is no module named MySQLdb. It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Python module and the script should work without any problem.
Using Python Pip
pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python
Successfully installed MySQL-python-1.2.5
On Ubuntu based systems
# apt-get install python-mysqldb
On RHEL/CentOS based systems:
# yum install MySQL-python
Using easy_install
# easy_install mysql-python
If you are on a virtual environment then
pip install MySQL-python
You can also check this related issue.
** Building wheel for MySQL-python (setup.py) ... error
ERROR: Command errored out with exit status 1:**
can't able to install MySQL-python and getting the above error .
When I try to run my server using:
./manage.py runserver 0.0.0.0:8000
I get the following error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
After browsing for a solution, I learned that Django was not installed so I tried installing it on a VM.
I tried the following:
pip install django
yum install django
yum install python-django
I also tried running these commands with sudo -s and sudo -E.
I am getting the following when I use pip cmd:
Downloading/unpacking django
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement django
No distributions at all found for django
Storing complete log in /root/.pip/pip.log
Using Yum I get:
No package python-django available.
Error: Nothing to do
Install a new version of Python. Pip has to be installed for the new
version. CentOS 6.6 has default Python 2.6 and the default pip
doesn't work properly.
Install Django with new pip.
Do not install the new version of Python globally as CentOS relies on
Python 2.6 for yum.
I've just installed python 2.7 from source for my Debian Squeeze. But now, when I use virtualenv, for this specific python version, I have this error:
~/ENV$ virtualenv -p /usr/local/bin/python2.7 --no-site-packages --distribute script_prod
Traceback (most recent call last):
File "/usr/bin/virtualenv", line 2, in <module>
import virtualenv
ImportError: No module named virtualenv
How can I fix it?
I've found out that I need to install virtualenv with python2.7 in order to make it works!