Custom python install location: tkinter problems - python

I'm using Ubuntu 14.04. While I have to retain my "main" python install as 2.7.6, I need to install 2.7.9 to be able to use ssl.SSLContext, to get Flask to deal with HTTPS requests.
However, if I just do:
sudo make install
or
sudo make altinstall
in the Python-2.7.9 directory, I ultimately get:
make: *** [libinstall] Error 1
EDIT: this appears at the end of sudo make install:
...
Compiling /usr/local/lib/python2.7/xml/sax/saxutils.py ...
Compiling /usr/local/lib/python2.7/xml/sax/xmlreader.py ...
Compiling /usr/local/lib/python2.7/xmllib.py ...
Compiling /usr/local/lib/python2.7/xmlrpclib.py ...
Compiling /usr/local/lib/python2.7/zipfile.py ...
make: *** [libinstall] Error 1
So I installed it to a custom directory by modifying the call to ./config, which did not yield the libinstall error.
However, when I try to import Tkinter into Python 2.7.9 (running from the custom directory) I obtain:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/repos/Python279/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
If I just go ahead and install the vanilla way (i.e., to a non-custom directory) and simply ignore the libinstall error I get, upon importing Tkinter:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: /usr/lib/python2.7/lib-dynload/_tkinter.so: undefined symbol: PyFPE_jbuf
Does anyone have any idea what is going on?

Following furas' suggestion, installing via the
Python 2.7 PPA maintained be Felix Krull worked spectacularly. Thanks Furas!
EDIT Some notes:
Because this PPA installs python2.7 (specifically v. 2.7.11, as of 1/29/2016), this obviated the need for a custom python install location
While the PPA website mentions that this doesn't include python-tk, provided you have installed it, python plays with it just fine (solving my problem)

First of all source code from a program must be configured, compiled, then installed. You can do this by:
./configure # Or ./config depending on the file name
make
make install
Second of all when you tried to import the module _tkinter you wanted to import the .py file which was called Tkinter.py
Try to use:
import Tkinter

Related

Not able to install bz2 in Python 3

I am not able to install the bz2 package in Python 3 Can please anyone guide
I followed the below commands
sudo yum install bzip2-devel
after that, I start my python 3.7 terminal and use the below command
import bz2
The error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/sysopt/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
Based on the comments and the /usr/local/sysopt path, I assume you've installed Python 3.7 from a source package.
When you did that, the Python configure script checked whether it has the bits to compile the bz2 module, and as you didn't have bzip2-devel installed during that time, the builtin bz2 module didn't get compiled.
You will need to recompile and reinstall Python 3.7 to get it included. At that point, you may also want to pay heed to any other optional modules that inadvertently don't get installed; sqlite3 tends to usually be one that ends up missing!

Install custom sklearn

I forked the scikit-learn repository, added a file that I need and downloaded the repository. I am not sure how to use this custom library. I cd'ed to the scikit-learn-master folder and tried to use it but it throws errors. So after reading the errors I installed it using python3 setup.py install. There were two setup.py files. One in the scikit-learn-master folder and sklearn folder so I ran python3 setup.py install at both these locations. They threw some warnings but no errors. I opened the python terminal in the scikit-learn-master folder and used import sklearn which returns the following -
Traceback (most recent call last):
File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 44, in <module>
from ._check_build import check_build # noqa
ModuleNotFoundError: No module named 'sklearn.__check_build._check_build'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__init__.py", line 128, in <module>
from . import __check_build
File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "/Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named 'sklearn.__check_build._check_build'
___________________________________________________________________________
Contents of /Users/shubhamgandhi/Desktop/scikit-learn-master/sklearn/__check_build:
__init__.py __pycache__ _check_build.c
_check_build.pyx setup.py setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
I am not sure how to proceed. Is there anything I am missing?
It appears the module has not been built correctly. And so it shows importError for check_build.
Before installing the module using pip, make sure you have installed all of the dependencies. On the README file, the mentioned packages are:
Python (>= 2.7 or >= 3.3)
NumPy (>= 1.8.2)
SciPy (>= 0.13.3)
For running the examples Matplotlib >= 1.1.1 is required.
If you are not planning on contributing to the project, but only using it, it is recommended that you download from https://pypi.python.org/pypi/scikit-learn instead of forking it.
View detailed instructions on how to install here.
After installing and building this way, if you still have issues, you can refer http://scikit-learn.org/stable/faq.html for FAQs.

wxPython import error with Windows install

I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.

Error during library import in Python (Windows)

I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.

Import module CairoPlot fails in Python

I'm using cairo plot to draw charts with python. I followed the instruction as stated on the website to install Cairplot, http://linil.wordpress.com/2008/09/16/cairoplot-11/ :
sudo apt-get install bzr
bzr branch lp:cairoplot/1.1
The installation completes successfully.
I then try to import the modules in python:
>>> import CairoPlot Traceback (most recent call last): File "<stdin>",
line 1, in <module> ImportError: No
module named CairoPlot
>>> import cairo
>>>
Importing cairo is fine, but I can't figure out why I am not able to import CairoPlot.
bzr branch lp:cairoplot/1.1 creates a directory called 1.1 in your current working directory. Inside you'll find CairoPlot.py. Move CairoPlot.py into a directory which is listed in your PYTHONPATH, or edit your PYTHONPATH to include (the unfortunately named) 1.1.
Is the directory where CairoPlot is installed in your $PYTHONPATH? Do you need to run any setup scripts, like setuptools?
The repository appears to include a setup.py file, so you likely need to run setuptools to fully install the module.

Categories

Resources