I am unable to install module pandas in my linux vm. I tried all ways to install it, but it says it has version 1.1.5 requirement already satistied. But when I try running the code, it says, no module found. The latest version of python in it is 2.7.3, but I want to install 3.8 or 3.7, but I'm unable to. Where am I going wrong?
Did you try installing python3 from your package manager? You can install python 3.9 from apt using the below command
apt install python3 pip -y
You can also install the below package to use python in the terminal instead of python3 every time
apt install python-is-python3 -y
I cant comment yet so using the answer section, kindly give me an upvote so I can start using the comment feature, sorry for the trouble
I am using imports :-
import psycopg2
But while running the code in local, I am facing an issue of :-
from psycopg2._psycopg import (
ModuleNotFoundError: No module named 'psycopg2._psycopg'
I have installed psycopg2 using cmd [pip install psycopg2]
psycopg2 version 2.8.4
python version 3.7.3
python 3.7 32bit
How should I import the ._psycopg.py file in windows? or any other solution if possible?
I'm also facing the same problem. It took me 2 days to pulled out my hair until I found the solution.
What I've been tried
Here's what I have been doing to solve this issue BUT DIDN'T SOLVE THE PROBLEM. I hope it will help anybody else who has the same problem.
Install "psycopg2" and "psycopg2-binary"
pip install psycopg2
pip install psycopg2-binary
Install "libpq-dev"
sudo apt install libpq-dev
Install "python-psycopg2" and "python3-psycopg2"
sudo apt install python-psycopg2 python3-psycopg2
Install "python-dev" and "python3-dev" and "python3.9-dev"
sudo apt install python-dev python3-dev python3.9-dev
Install "python-setuptools"
sudo apt install python-setuptools
Unfortunately, none of my effort above solve my problem.
What's the solution
So, here's my solution that I've been try and IT WORKS
Install the latest mod_wsgi from Github.
You should install this latest 'mod_wsgi' in order to your wsgi able to use Psycopg2 library. Here's my step to do it :
Go to release page mod_wsgi on Github (https://github.com/GrahamDumpleton/mod_wsgi/releases)
Download the file from latest version. As I write this, the latest version is 4.7.1 (https://github.com/GrahamDumpleton/mod_wsgi/archive/4.7.1.tar.gz)
Follow the installation guide from official docs.
Unpacking source code
tar xvfz mod_wsgi-4.7.1.tar.gz
Configure source code
./configure
Build the source code and install
make
make install
Restart apache server
sudo service apache2 restart
This solution has works on my machine (Ubuntu 18.04 & Python 3.9 Venv).
Alternative solution
Here's some solution from others.
Saray Chak's solution
As u can see from the question, I run sudo pip install pymysql successfully.
But it seems to be installed in 2.7.10 rather 2.7.13. I find it when tried to get python version before as well as after using sudo -i.
Then I listed all modules install using help('modules') and suprisingly to find 2.7.10 has but 2.7.13 don't have pymsql .
It failed to run pip2.7.13 install pymysql .Only pip2.7 install pymysql works .
I wonder how to config pip to install modules to 2.7.x or change my default python version from 2.7.13 to 2.7.10 ?
You may try to install python packages without root permission:
pip install --user pymysql
The option --user allow pip to install packages in your \home directory instead. That means it doesn't need any special privileges.
I finally find the cause:
My computer has an software named MAMP which has python2.7.13 env itself and pushes the python to the global.But pip will install modules into the computer's own python2.7.10, which causes now global python2.7.13 cannot import the installed modules.
Solution:
1,Find out the location of modules installed by pip and copy them to the
python directory in mamp. Commands as below:
cp -r /Library/Python/2.7/site-packages/pymysql/* /Applications/MAMP/Library/lib/python2.7/pymysql/
2, Then I can feely import modules installed by pip in global python now ~
I am new to django
I would like to start a project but when i run it i get this error
Error loading MySQLdb module
How do i add the MYSQL module or any other module for that matter
Install it on your system, using either a native installer or package, via pip or easy_install, or by running setup.py in the tarball.
you should install a mysql client and a mysql python client for that client. So you should execute following commands(For Debian systems)
apt-get install mysql-client
apt-get install python-mysqldb
I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run install script for django, I get
amitoj#ninja:~/Django-1.2.1$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from distutils.core import setup
ImportError: No module named distutils.core
I'm stumped. All the articles on internet tell me how to install modules using distutils. But how do I get distutils itself? Can anyone point me to the archive for distutils? I looked in /usr/lib/local/python2.5, /usr/lib/python2.5 etc, and as expected there is no distutils to be found.
I know this is an old question, but I just come across the same issue using Python 3.6 in Ubuntu, and I am able to solve it using the following command (this works in Ubuntu 18.04, 20.04 and 22.04):
sudo apt-get install python3-distutils
If you are unable to install with either of these:
sudo apt-get install python-distutils
sudo apt-get install python3-distutils
Try this instead:
sudo apt-get install python-distutils-extra
Ref: https://groups.google.com/forum/#!topic/beagleboard/RDlTq8sMxro
you can use sudo apt-get install python3-distutils by root permission.
i believe it worked here
You can install the python-distutils package. sudo apt-get install python-distutils should suffice.
I ran across this error on a Beaglebone Black using the standard Angstrom distribution. It is currently running Python 2.7.3, but does not include distutils. The solution for me was to install distutils. (It required su privileges.)
su
opkg install python-distutils
After that installation, the previously erroring command ran fine.
python setup.py build
The simplest way to install setuptools when it isn't already there and you can't use a package manager is to download ez_setup.py and run it with the appropriate Python interpreter. This works even if you have multiple versions of Python around: just run ez_setup.py once with each Python.
Edit: note that recent versions of Python 3 include setuptools in the distribution so you no longer need to install separately. The script mentioned here is only relevant for old versions of Python.
The module not found likely means the packages aren't installed.
Debian has decided that distutils is not a core python package, so it is not included in the last versions of debian and debian-based OSes. You should be able to do
sudo apt-get install python3-distutils
sudo apt-get install python3-apt
If you are in a scenario where you are using one of the latest versions of Ubuntu (or variants like Linux Mint), one which comes with Python 3.8, then you will NOT be able to have Python3.7 distutils, alias not be able to use pip or pipenv with Python 3.7, see:
How to install python-distutils for old python versions
Obviously using Python3.8 is no problem.
This didn't work for me: sudo apt-get install python-distutils
So, I tried this: sudo apt-get install python3-distutils
If the system Python is borked (i.e. the OS packages split distutils in a python-devel package) and you can’t ask a sysadmin to install the missing piece, then you’ll have to install your own Python. It requires some header files and a compiler toolchain. If you can’t have those, try compiling a Python on an identical computer and just copying it.
By searching all python-distutils related package:
apt-cache search x
I get python3-distutils-extra - enhancements to the Python3 build system
Then just try:
sudo apt-get install python3-distutils-extra