solaris python setuptools install - python

I have a solaris host:
SunOS blah 5.10 Generic_147441-27 i86pc i386 i86pc
and I have python at /usr/bin/python
$ /usr/bin/python
Python 2.6.4 (r264:75706, Jun 26 2012, 21:27:36) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>>
the problem is that I do not appear to have setuptools installed, so I download the tarball and try:
setuptools-0.6c12dev-r88846$ /usr/bin/python setup.py install
Traceback (most recent call last):
File "setup.py", line 4, in <module>
from distutils.util import convert_path
ImportError: No module named distutils.util
and of course, because I don't have distutils, I can't install... well anything.
I'm not familiar with solaris at all; some googling indicated that I need python-dev installed. how do I do that? any other suggestions?

You can use Python from OpenCSW. There you'll get a Python package and many modules, including setuptools. Available Python versions are Python 2.6 (CSWpython), 2.7 (CSWpython27) and 3.3 (CSWpython33). Most module packages are available for Python 2.6 and 2.7. Assuming you've got started with OpenCSW and added /opt/csw/bin to PATH, you can:
sudo pkgutil -y -i python py_django
To get modules for Python 3.3, can use virtualenv and pip as a regular user. For example:
sudo pkgutil -y -i python33 virtualenv
virtualenv -p /opt/csw/bin/python3.3 py3env
source py3env/bin/activate
pip install django

Related

How to install gi module for anaconda python3?

python3 is my local Anaconda version of python, while python3.4 is the system one. I can import gi module with python3.4 (probably because i installed it with sudo apt-get install python3-gi) but python3 doesn't see it:
$ python3 -c 'import gi'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named 'gi'
$ python3.4 -c 'import gi'
$ python3 --version
Python 3.5.1 :: Anaconda 4.0.0 (64-bit)
$ python3.4 --version
Python 3.4.3
$ which python3
/home/kossak/anaconda3/bin/python3
$ which python3.4
/usr/bin/python3.4
$
How should i install gi for Anaconda python? Or maybe i can somehow import sysem-wide modules?
My os:
System: Kernel: 3.19.0-32-generic x86_64 (64 bit gcc: 4.8.2) Desktop: Cinnamon 2.8.8 (Gtk 2.24.23) dm: mdm
Distro: Linux Mint 17.3 Rosa
If you're using conda virtualenv for python-3, you can use
$ conda install -c conda-forge pygobject
in your virtualenv
You can read more about this on:
https://anaconda.org/conda-forge/pygobject
This is how you do it: (example for Linux Mint and python3)
First install gi module using your distro package manager. For Linux Mint it would be:
sudo apt-get install python3-gi
Then run your distro python to check where the module is located:
$ /usr/bin/python3
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> print(gi)
<module 'gi' from '/usr/lib/python3/dist-packages/gi/__init__.py'>
So in my case the module gi was installed to /usr/lib/python3/dist-packages/gi. Assuming you have your anaconda installed in /home/kossak/anaconda3, create a link to gi module in the proper folder:
ln -s /usr/lib/python3/dist-packages/gi /home/kossak/anaconda3/lib/python3.5/site-packages/
If you have conda virtual environment and want gi module to be available there, the path should be a bit different. Assuming the virtual env is called TEST:
ln -s /usr/lib/python3/dist-packages/gi /home/kossak/anaconda3/envs/TEST/lib/python3.5/site-packages/
and it works:
$ python3
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>
If you want to perform a proper install (without soft linking) inside a Linux anaconda environment. Keep in mind that the errors may vary if you have not installed gcc previously (I assumed it was installed by default when I posted, however not everyone does so). Install it if you don't know very well what you're doing to avoid missunderstandings
Create or open your conda environment.
Attemp to install pygobject (don't worry, it will most likely throw an error):
pip install pygobject
In linux, it will promp the usual installation progress followed by an error:
(...) Please, try executing the following in your system:
sudo apt install libgirepository1.0-dev
Depending on your operation sistem or installed dependencies, the command name or package name may vary. Just follow the instructions and allow the system to install your packets. This step doesn't change anything, is just to give you the precise info of the package you need on your system. If you run this on Windows, it will ask you to install a specific version of Visual Studio. If you are in Windows, download the required Visual Studio from MS website, install it, reboot your computer and go to step 5 (in my case I never needed step 4 in windows, however, I'm not a MS expert.
Close your conda environment
conda deactivate
Next you need to install pygobject from conda-forge repository in your conda environment. You can add the repo to your favourite conda package manager or simply run the following command as root (it is important to be root). I did it outside the project, but you may do it inside:
conda install -c conda-forge pygobject
In my case conda was not in the path. I had is installed in:
/opt/anaconda3/bin/
You can run the following command from your normal user to find out where conda is:
which conda
Open the conda environment
source activate <your env name>
or the corresponding anaconda activate syntax (I never use it so I cant remember precisely)
Repeat the first step and now the installation wont fail:
pip install pygobject
OR if you specifically want to install gi you can run:
pip install pgi
the correct package is "pgi" NOT "gi"
As gi is a dependency of pygobject, everything will get properly installed. You can check it by running
python
>>> import gi
You may find the following usefull for Windows, although you may need to work it out a bit:
GStreammer python bindings on Windows
for me
conda install -c pkgw/label/superseded gtk3
worked

ImportError: cannot import name 'PrintTable' in Python 3.5.1 by pyenv

I installed pyenv to manage different versions of Python, and use pip install printtable to download and install printtable.
But when I import this module in interactive shell, it doesn't work and shows ImportError.
$ pyenv versions
system
2.7.11
* 3.5.1 (set by /Users/apple/.pyenv/version)
$ pip list
pip (8.0.0)
printtable (1.2)
setuptools (18.2)
$ python
Python 3.5.1 (default, Jan 21 2016, 12:50:43)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import printtable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/apple/.pyenv/versions/3.5.1/lib/python3.5/site-packages/printtable/__init__.py", line 1, in <module>
from printtable import PrintTable
ImportError: cannot import name 'PrintTable'
How can I manage the modules in pyenv?
PS. I'm following the book Automate the boring stuff step by step. The printtable part is in the end of Chapter 6.
Visit: https://automatetheboringstuff.com/chapter6/
I downloaded printtable with
pip3 install --download /tmp printtable
and inspected the contentents of printtable-1.2.tar.gz. In printtable/printtable.py there is code like
def printTable(self,line_num=0):
....
print self.StrTable
indicating that this package is not python 3 compatible.
It may be possible to install this module by
tar xfv printtable-1.2.tar.gz
cd printtable-1.2/
2to3-3.5 --write printtable/*.py tests/*.py
python3.5 setup.py build
python3.5 setup.py install
You’re not doing anything wrong; the printtable module is simply written in a way that’s entirely incompatible with Python 3.
Since you’re already using pyenv, and according to the output of pyenv versions you already have Python 2.7.11 installed, you can simply install printtable for that Python interpreter:
pyenv shell 2.7.11
pip install printtable

Python3 has no acces to python2 modules (ubuntu)

Im fairly new to programming and Ubuntu. Yesterday I finally managed to create a dual-boot system, so now I'm running Ubuntu 12.04 LTS.
For a school project, I need to work in Python3 with a module called SPARQLWrapper (https://pypi.python.org/pypi/SPARQLWrapper).
On my freshly installed Ubuntu, I've installed the latest version of Python. When I type "python3" in my terminal, python 3.2.3 starts so thats good.
I installed easy_install (sudo apt-get install python-setuptools), and downloaded and installed the SPARQLWrapper egg file (sudo easy_install SPARQLWrapper-1.5.2-py3.2).
If I run python2 and use "import SPARQLWrapper", it just works. But if I try the same in python3 it gives me the following error:
x#ubuntu:~$ python3
Python 3.2.3 (default, Oct 19 2012, 20:10:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import SPARQLWrapper
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named SPARQLWrapper
So my problem is that python3 isn't able to acces the same modules as my python2. How do I fix this?
Thanks!
To install packages for Python3, you need python3's setuptools.
Following are the steps to be followed to install python3's setuptools and SPARQLWrapper
sudo apt-get install python3-setuptools
sudo easy_install3 pip
pip -V This should show the pip corresponding to your python3 installation.
sudo pip install SPARQLWrapper
After doing the above mentioned steps, I get this
~$ python3
Python 3.3.1 (default, Apr 17 2013, 22:30:32)
[GCC 4.7.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import SPARQLWrapper
>>> exit()
~$
Each Python installation has its own modules directory. In addition, Python 3 is not backwards compatible and won't generally run Python 2 code. You'll need to find a Python 3 version of the module you need and install it for Python 3.

zlib cannot be installed using yum

I am working on a RHEL system. I have two versions of Python installed on my system: Python 2.4 and Python 2.7, but I have created an alias in the .bashrc file so that the python command prompts Python 2.7 instead of Python 2.4.
I need to install zlib in my system. I tried to install it using the yum command:
yum install zlib
yum install zlib-devel
both worked fine, but when I type "python", I still cannot see zlib installed:
[root#mymachine]# python
Python 2.7 (r27:82500, Jan 18 2012, 17:03:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named zlib
But if I import zlib from Python 2.4, it works! Why? I need zlib to be installed using Python 2.7. How can I do that? Thank you in advance!
Generally you will only find RPMs for the default Python version in the yum repository, however that shouldn't really be applicable here since zlib should be installed by default in your Python 2.7 installation.
Check sys.path using import sys; print sys.path and make sure that you have the lib directories for your Python 2.7 installation, it is possible that whatever you are doing in .bashrc is causing you to pick up the Python 2.4 environment.
Here is the location of my zlib module, which may be useful in trying to track down the location of yours so you can make sure it is on sys.path.
>>> import zlib
>>> zlib
<module 'zlib' from '/usr/local/lib/python2.7/lib-dynload/zlib.so'>
If you cannot find it then you should reinstall Python 2.7.
The zlib and zlib-devel packages are the C shared and development libraries, respectively; the zlib you are importing in Python 2.4 is the one that shipped in the python-libs package:
$ rpm -qf /usr/lib64/python2.4/lib-dynload/zlibmodule.so
python-libs-2.4.3-46.el5
I don't know where you got your Python 2.7 from, but zlib is part of the standard library--it should have been built with Python. You will need to acquire a zlib module that was built against Python 2.7.

Can't install module with python-pip properly

I would like to install a module but pip is not installing it in the right directory which I assume should be /usr/local/lib/python2.7/site-packages/. After all, I just installed Python 2.7.2 today. Originally I had 2.6.5 and had installed modules successfully there. So I think something is wrong with my Python path.
How to have all my module installations go to the proper python2.7 directory?
s3z#s3z-laptop:~$ pip install requests
Requirement already satisfied: requests in /usr/local/lib/python2.6/dist-packages/requests-0.6.1-py2.6.egg
Installing collected packages: requests
Successfully installed requests
s3z#s3z-laptop:~$ python
Python 2.7.2 (default, Oct 1 2011, 14:26:08)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
>>> ^Z
[3]+ Stopped python
Also here is what my Python directories look like now http://pastie.org/2623543
After you installed Python 2.7, did you install the Python 2.7 version of easy_install and PIP? The existing installations are configured to use Python 2.6 by default which may be causing your issue.
You are probably using pip linked to python2.6, instead of 2.7. If you have installed pip properly with python2.7, you can do:
pip-2.7 install requests
If not, try installing this way:
curl -O http://python-distribute.org/distribute_setup.py
[sudo] python2.7 distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
[sudo] python2.7 get-pip.py

Categories

Resources