Problem installing Python-Dev
Solution 1
This bit:
python2.7-dev : Depends: python2.7 (= 2.7.3-0ubuntu3) but 2.7.3-0ubuntu3.1 is to be installed
suggests that you are using some mismatched repositories, or have some apt-pins in place keeping the version dependencies from lining up. I think, specifically, python-2.7 2.7.3-0ubuntu3.1
is in the Precise-proposed
repository and the 2.7.3-0ubuntu3
version is in Precise/main proper, so you may be preferring -proposed for some but not all packages.
Can you edit your question to include the output of:
apt-cache policy python2.7-dev
apt-cache policy python2.7
and maybe:
apt-cache show python2.7
...
Reading the apt-cache output from your pastebin, it looks like you have the python2.7 2.7.3-0ubuntu3.1
from precise-updates/main
installed, but python2.7-dev
is from precise/main
. I think your install media or an earlier "apt-get update" included the precise-updates
repository, but it's not in your current sources.list.
I think you'll be able to get the install going after adding precise-updates
and then apt-get update
.
echo "deb http://us.archive.ubuntu.com/ubuntu/ precise-updates main restricted" | sudo tee -a /etc/apt/sources.list.d/precise-updates.list
sudo apt-get update
sudo apt-get install python2.7-dev
Solution 2
You shouldn't install numpy with pip, use the package Ubuntu provides:
dennis@koekblik:~$ apt-cache show python-numpy
Package: python-numpy
Priority: optional
Section: python
Installed-Size: 7616
...
As to your actual problem: try installing python2.7-dev
. It will likely fail but should give you a better error message.
Solution 3
fastest solution:
- Install (
sudo apt-get install synaptic
) Synaptic Package Manager and start it - Click on Settings-Repositories
- Select Download from: Main Server
- Click Close then click on Reload.
- Mark
python-dev
for installation and Synaptic will also mark all dependencies ofpython-dev
(libexpat1-dev, libssl-dev, libssl-doc, python2.7-dev, zlib1g-dev
).
I have just resolved the same problem on freshly installed Ubuntu x86 12.04.3.
Related videos on Youtube
john_science
Excited about the places where science and software meet. Currently working in nuclear reactor design. Eternal student. (Rock Climbing and bread baking for fun.)
Updated on September 18, 2022Comments
-
john_science over 1 year
I am having trouble installing
python-dev
. It all started when I tried to install another Python package and got the error:SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev.
I tried
sudo apt-get install python-dev
but got the error:The following packages have unmet dependencies: python-dev : Depends: python2.7-dev (>= 2.7.3) but it is not going to be installed E: Unable to correct problems, you have held broken packages.
So then I tried
sudo apt-get install python2.7-dev
and got the error:The following packages have unmet dependencies: python2.7-dev : Depends: python2.7 (= 2.7.3-0ubuntu3) but 2.7.3-0ubuntu3.1 is to be installed Depends: libpython2.7 (= 2.7.3-0ubuntu3) but 2.7.3-0ubuntu3.1 is to be installed
I have tried most everything in the post unmet dependencies. I am running Ubuntu 12.04 and I have everything updated. I have done
apt-get clean
andapt-get autoclean
. I have triedapt-get -f install
and all variations on that theme. I have cleaned up my PPA. I even tried using Aptitude, and though it did a lot of clean up, the result was the same.I really want to be able to install python-dev. How can I make this happen? At this point, I am willing to consider extreme options, whatever they may be.
-
RobotHumans about 11 yearsThe problem isn't installing python-dev. The problem is getting src and include folders propogated to your virtualenv.
-
john_science about 11 yearsDo you have any suggestions there? I was using
--system-site-packages
. -
RobotHumans about 11 yearsRead this: pythoncentral.org/… it explains how it actually works.
-
john_science almost 11 years@CallmeV This is a great post, but sadly doesn't address the problem I'm having getting Python-Dev to install.
-
Rodrigo Martins de Oliveira almost 11 yearsDo you have
python
installed? (sudo apt-get install python
) -
john_science almost 11 years@RodrigoMartins Oh yes, I have written many thousands of lines of Python code. But so far using only the standard libraries, thus the need to get python-dev working.
-
nilsonneto almost 11 years@theJollySin - what version of ubuntu are you using? Please disable all PPAs and run
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
. Paste the output to paste.ubuntu.com -
john_science almost 11 yearsHere is what you were looking for: paste.ubuntu.com/5775975
-
-
john_science about 11 yearsOkay, your first statement: there are other packages (like
gdal
) that would be much easier if I could install through PIP. Your second point, I can try that and see what happens. Thanks. -
Dennis Kaarsemaker about 11 yearsI agree that pip is a useful tool, but please stick to Ubuntu packages as much as possible, much easier for updating. And if you use pip to install packages, you might want to create yourself a virtualenv so you don't need to install as root into /usr/local.
-
john_science about 11 yearsOkay, I will try to stick to Ubuntu packages. But this whole problem started because I can get
numpy
working fine, but can't getnumpy
imported inside avirtualenv
. Having a workingvirtualenv
system for Python development is definitely the goal. Thanks again. -
Dennis Kaarsemaker about 11 yearsThat's a different question though :) Use a virtualenv with --system-site-packages to get access to what's installed via apt.
-
john_science almost 11 yearsI pasted the response to
apt-cache policy python2.7
and the like here: paste.ubuntu.com/5775963 -
Mostafa Ahangarha about 8 yearsIt is not necessary to give such introduction. Just give your answer. As per my experience, not always
unmet dependency
can be solved by usingsudo apt-get update