which version of python packages require - python

I have numerous versions of python installed, a system python with my mac osx (10.8), and numerous version from macports. On occation I have run into errors with different packages requiring different versions of python to run, and previously I could solve my problems by running a certain version explicitly (e.g. python2.6 <script>) or by changing my default python using port select python <python-version>.
I just struggled tremendously through installing the VTK (visualization) packages, and finally got them working by using /usr/bin/python instead of my standard /opt/local/bin/python. These are both version 2.7 (the former is 2.7.2 and the latter 2.7.5), however. Why can I only use one and not the other? Is there a way to use the /opt/ version and still have the vtk package work?
Examples of errors using the wrong python interpreter:
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
and,
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap

Related

The standard Python 3.6 module tries to call python 3.8

I am using python 3.6.8. When I try to import pyexpat, I get a "Module use of python38.dll conflicts with this version of Python." conflict. I checked the documentation and this module should be supported from at least 2.x+ python version. I've tried running my script both through the conda environment through visual studio (python 3.6.8) and through a priginal python 3.6.6 and 3.6.8. I am getting this error anyway.
It is very strange. How can python version 3.6.8, which I just downloaded from the official site, refer to version 3.8 if it is a clean new installed version?
There are too few tutorials on this module, but it should definitely work from early versions of python.
Have any ideas what can be done? I repeat once again that I literally run unmodified python without any modules and it still doesn't work.

How do I change the kernel/python version for iPython?

I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.

Lubuntu with python 2.7.8 and 3.4.2 import rrdtool

due to problems when installing rrdtool on windows i decided to switch to Linux to solve many problems.
I've installed Lubuntu (that has python 2.7.8 installed by default) and python 3.4.2.
Than with packet manager i've installed python-rrdtool.
The problem is: from the terminal when i write "python2" and than "import rrdtool" it works, but when i write "python3" import "rrdtool" it says to me that there are no module. How can i use rrdtool also on python3?
thanks
Paolo
Unfortunately python-rrdtool package from Ubuntu/Debian is a python 2.x package only. So it will work in python 2.7 and not in python 3.4.
If you must use rrdtool in python 3.x then you will have to use some alternative python to rrdtool binding. There are several to choose from if you look at pypi.python.org (which you can then install with pip). I have not used them as they all seem to have low version count and am weary of possible bugs. If someone did try those perhaps they could share their experience...

I get python errors with installing pre-requisites onto a node.js project

I am installing all the packages needed in a node.js project I downloaded and I am getting a ton of errors that I have no idea how to resolve them. It seems to be involved with getting python to run. I have both 2.7 and 3.3 on my computer.
Here are some images of the errors
The issue is that Python 2.7 is either not on your PATH or else is after Python 3.3. You can solve this problem by either:
Passing the path to Python 2.7 using the --python flag (as it states in the error) or
By adding the path to Python 2.7 (C:\Python27, most likely) to your PATH (or by moving it before C:\Python33 in the list).
You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0
Did you try that?
The problem here is that apparently to build that module, Python 2 is required, but your standard Python executable in the PATH is the Python 3 executable.
Other than that, it might be a good idea to ask the module maintainer to upgrade his build process to support Python 3 too.
if python2 is in your path (applies to a lot of linux setups)
npm install node-gyp-package --python=python2

python installation can't find psycopg2 ImportError

I'm calling on psycopg2 with
import psycopg2
I get the std error
ImportError: No module named psycopg2
I installed my copy with macports, so I'm curious why it wouldn't work because all of the dependencies should be downloaded as well.
I don't have any experience with Postgresql, nor this module, so I don't know what could be going wrong. Fact is, another project I'm trying to get built calls upon it, so if I could avoid using this I would. :)
I'm sure that postgresql is installed, but that has little to do with the fact that my installation can't find psycopg2. Any suggestinos would be appreciated.
$ which python
reveals
/Library/Frameworks/Python.framework/Versions/Current/bin/python
and
$ python --version
reveals
Python 2.7.3 -- EPD_free 7.3-2 (32-bit)
I don't necessarily want the version of EPD_free, but I had to install it for (somewhat) unrelated reasons.
MacPorts installs its own version of Python alongside Apple's version. You can manage the active version of Python (the one that gets run when you type in python at the command line or by /usr/bin/env) by using the port select command. See this question.

Categories