Problems upgrading to Python 3.3 and setting up Django - django

I'm new to Linux and am trying to set up Python / Django on my machine! I installed Python 3.3 from the source file and it was compiled into /usr/local/bin. Then I created a symbolic link between /usr/bin/python and /usr/local/bin/python3, so that whenever I invoke python from the command line it uses the latest version.
Now I am trying to install MySQL Python and I got the following output:
apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-mysqldb is already the newest version.
The following extra packages will be installed:
apt-listchanges python-apt
Suggested packages:
python-glade2 python-gtk2 python-apt-dbg python-vte python-apt-doc
The following packages will be upgraded:
apt-listchanges python-apt
2 upgraded, 0 newly installed, 0 to remove and 142 not upgraded.
3 not fully installed or removed.
Need to get 0 B/394 kB of archives.
After this operation, 250 kB of additional disk space will be used.
Do you want to continue [Y/n]? Y
Traceback (most recent call last):
File "/usr/bin/apt-listchanges", line 28, in <module>
import apt_pkg
ImportError: No module named 'apt_pkg'
Any ideas on how to fix this? Or any tips on how to clean up this install (if this one is too broken)?

Re-installing Python (apt-get install --reinstall python) should fix your installation issue.
Note that your approach will result in a lot of brokenness. Changing system Python version involves far than just changing symlinks, which is why you should leave it to the distro makers (see a similar question).
One other fact is that Debian already packages 3.3 (currently in Experimental), so rather install that. I just don't know if the system Python modules (e.g. python-apt) will work with it. If not, just use 3.2.
One other thing, if you want to use python-mysqldb, you have to stick to Python 2, because it will not run with Python 3. If you insist on Python 3, use python3-mysql.connector.

Related

Installing NumPy + SciPy in Python 2.7 now fails with "RuntimeError: Python version >= 3.5 required"

Installing numpy and scipy from source like this (say, in a fresh Python 2.7 pyenv virtualenv):
pip install numpy==1.14.6 scipy==1.0.1 --no-binary numpy,scipy
gets their installers to use a ~/.numpy-site.cfg file that points to my openblas installation.
This used to work. Now it produces a long stack trace ending with:
File "/usr/local/var/pyenv/versions/2.7.16/envs/issue/lib/python2.7/site-packages/setuptools/sandbox.py", line 45, in _execfile
exec(code, globals, locals)
File "/var/folders/_b/q30qg_l50b5gvqd8y4_wb9h00000gn/T/easy_install-o9MJ5E/numpy-1.17.1/setup.py", line 31, in <module>
if sys.version_info[0] < 3:
RuntimeError: Python version >= 3.5 required.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Q. What changed?
Q. Why does it say Python version >= 3.5 required. in a Python 2.7 installation?
Q. How to fix it?
The scipy 1.0.1 installer requires numpy as a prerequisite, but the multiple installers working together end up getting the latest version of numpy unless numpy is already present.
What changed: The latest version of numpy requires Python 3.5+, hence the error message.
So even though the pip command explicitly asked to install numpy==1.14.6 scipy==1.0.1, it triggers a newer numpy installer that fails on Python 2. (The last entry in the stack trace shows numpy-1.17.1 requiring Python 3.)
The problem arises in the interaction between pip, the scipy and numpy installers, and easy_install. Details in pip issue #6945.
Workaround: Install numpy first. Then install scipy. Alternatively, the one-line install might work if you don't need the --no-binary option.
I also encountered an issue where scipy was been installed through a script and it was trying to install a version 1.7.1 which required python 3.7 at least and i hand 3.6. The workaround was i installed scipy myself and the version i got was 1.5.4.

Can't install external packages in Python

My problem is when I'm trying to install an external package via Command Prompt, I'm getting an error. I've just started programming and I don't understand everything yet.
That's an error:
If Python 2 and Python 3 are both installed on the system, they can interfere and cause easy_install to break.
Hence, you will need to specify which version of Python and easy_install you want, like this:
python-2.7 -m easy_install <module>
For any other version of Python, just change the -2.7 to your major.minor version.

Anaconda Update - UNDESIRED Revert to Earlier Version

I am running anaconda on OS 10.11.6. I am not certain of the precise anaconda version that I previously had, but it was about 4-6 months old, I believe, and it was running Python 2.7.11. I wanted to update both python (to 2.7.12) and anaconda (while I was at it) and so I used the standard procedure of
conda update conda
conda update anaconda
This has worked swimmingly for me in the past. This time, however, it is taking me back to an earlier version of python (2.7.10) when I do this. From running conda --version I see that I have conda 4.1.11, which is the latest, as I understand it. However, when I run conda update anaconda I get a display saying:
anaconda 2.3.0 np19py27_0
Similarly, with python --version I get:
Python 2.7.10 :: Anaconda 2.3.0 (x86_64)
In my folder ~/anaconda/bin/ (which folder I also have in my PATH such that calls to python direct here) I have an alias named python which says that it was just updated today (which is when I ran the conda update, etc.). But, it just points to a file python 2.7 which is ins ~/anaconda/ and hasn't been modified since May 2015.
I figure if I did a complete uninstall and reinstall of anaconda, I could presumably clear this up. I'd rather avoid that if possible though, since it would mean reinstalling all the rest of my other python packages, etc.
I also saw this SO Post: Anaconda not updating to latest . but when I try:
conda install anaconda=4.1.1
I get the following error:
Fetching package metadata .......
Solving package specifications: ....
The following specifications were found to be in conflict:
- anaconda 4.1.1*
- gevent-websocket -> gevent 0.13.7|0.13.8|1.0|1.0.1|1.0.2|1.1.0
- gevent-websocket -> python 2.6*
Use "conda info <package>" to see the dependencies for each package.
Update: I ended up just wiping my old installation and installing a fresh version of Anaconda. It was a bit of a pain but it seemed like it would be less work than trying to track down what was happening with this bug. Still though, I'd be delighted in any solutions people have to this issue for future reference by me and others who encounter this.

How do I open a .whl binary installation file in CMD? Win Py 2.7 Err "No distributions at all found for lxml-3.4.4-cp27-none-win32.whl"

I've been at this for nearly 2 hours and I just can't seem to get my head around it. I am a novice Pythoner, it would appear. I am trying to intsall lxml, (needed to install scrapy). I have tried multiple methods (see my other current quesitons).
Currently I am trying the following.
I downloaded the lxml win 32 file for python 2.7 from this website:
https://pypi.python.org/pypi/lxml/3.4.4#downloads
The LXML Binaries are also available here: "http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml"
I download the .whl file.
I then open up CMD, and CD to my download folder. Once in that folder I run the following command (as per the answer to this question here: How do I install a Python package with a .whl file?)
pip install lxml-3.4.4-cp27-none-win32.whl
This is the output:
C:\Users\Charles\Downloads\python>pip install lxml-3.4.4-cp27-none-win32.whl
Downloading/unpacking lxml-3.4.4-cp27-none-win32.whl
Could not find any downloads that satisfy the requirement lxml-3.4.4-cp27- none
-win32.whl
No distributions at all found for lxml-3.4.4-cp27-none-win32.whl
Storing complete log in C:\Users\Charles\AppData\Roaming\pip\pip.log
Can anyone help me figure out what this means/what is going on? How can I execute this file to install the lxml as needed?
Many thanks!!
Edit: I am using Windows 64 bit, but from this question here: "easy_install lxml on Python 2.7 on Windows" the file I have selected appears to be the correct one.
I am using Windows 64 bit and use Scrapy. It took a while for me to figure out the best way to set up my virtualenv because lxml would not simply pip install.
So I did somethine very similar to what you did but it looks at first glance we may just be using different sites. So try downloading this .whl from HERE. Specifically, for your specifications I believe, grab the one that reads
lxml-3.4.4-cp27-none-win_amd64.whl
and then just cd to the downloads folder and pip install lxml-3.4.4-cp27-none-win_amd64.whl
The first thing you should do is upgrade pip; the latest version is 8.0. Next, you need to install wheel support (this step may be redundant in later versions) and then finally install your wheel:
pip install --upgrade pip
pip install wheel
lxml needs a lot of source-level dependencies, which are difficult to install in Windows. This is why the project provides binary installers for Windows. You can download these from the pypi page for lxml. Make sure you choose the right version for your environment:
lxml-3.4.4.win32-py2.7.exe - for Python 2.7 running on Windows 32-bit
lxml-3.4.4.win32-py3.2.exe - for Python 3.2 running on Windows 32-bit
lxml-3.4.4.win-amd64-py2.7.exe - for Python 2.7, running on Windows 64-bit

lapack/blas-related error when trying to add scipy to miniconda-installed copy of python 2.7.10 on RedHat 6

I have two versions of python on my RedHat 6 machine: 2.7.8 that came with the system originally and 2.7.10 that I've installed using miniconda for a project. I have to use the newer version to run some demo code for another project. The demo script produced this error:
ImportError: No module named scipy.sparse
Running pip install scipy failed with a bunch of warnings and then this:
numpy.distutils.system_info.NotFoundError: no lapack/blas resources found
numpy is already installed. That is, I get Requirement already satisfied when trying to pip install numpy.
The yum install command recommended on the SciPy install page completed fine but did not help, probably because this python version is installed at a non-default location.
Same result after building blas and lapack from source as described here
How do I get scipy to install properly?
Thx
I think you don't have lapack/blas library.
try this.
yum install python-devel python-nose python-setuptools gcc gcc-gfortran gcc-c++ blas-devel lapack-devel atlas-devel
it will install all what you need.
If you use Anaconda/miniconda, then use the conda package manager, not pip:
conda install scipy.
Value of a Peace of mind once starting always from a [Defined state]
There are many issues with pip / yum installer strategies that we, mortals, can spend ages on our attempts to get resolved.
Since I started to use the Travis Oliphant's Anaconda fully-fledged package-manager, these dependency-related / version-colliding issues simply disappeared. Well did not disappear, but principally do not appear.
Why?
Anaconda package-manager both allows one to keep separate versions ready / reconfigurable via Anaconda for individual python launches
and
Anaconda resolves updates in a smart way, one would never experience with manual/semi-manual pip/yum installers
In other words, if you strive to get rid of issues, opt to install Anaconda and start using it's (parallel) multi-versions installation / setup controls and it's smart package-manager facilities.
n.b.: this is not a commercial/spam/PR, this is just personal experience after many years of troubles with individual package updates' collisions / compatibility back-testing troubles in multi-py 2.5 / 2.6 / 2.7 installations environments