python install on leopard - python

I'll admit I'm completely dumbed by python install. Can someone help me on how to install module
I want to play with PyGame, PyOpenGL etc. So I install them, but I everytime I type "import pygame" error message shows up.
here's my environment so far.
In .bash_profile
PATH=${PATH}:/System/Library/Frameworks/Python.framework/Versions/Current/bin
Using easy_install PyOpenGL placed this
/Library/Python/2.5/site-packages/PyOpenGL-3.0.0b8-py2.5.egg
Locating pygame module
dchong:~ danielchong$ locate pygame
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2app/recipes/pygame.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2app/recipes/pygame.pyc
dchong:~ danielchong$ locate pyopengl
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2app/recipes/pyopengl.py
/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/py2app/recipes/pyopengl.pyc
when I run python
Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pygame

I'm not a huge fan of the default python install on OS X in the first place, mostly because it's usually a pretty old version. I find everything works better if I use the macports package.
easy_install seems to work better with the macports package, but maybe that's just because I'm too lazy to figure out all the nuances of the default install.
From what I can see there, it looks like the path to the packages isn't set correctly. Are you sure you're using the right site-packages directory?

See http://farmdev.com/thoughts/66/python-3-0-on-mac-os-x-alongside-2-6-2-5-etc-/

Related

Anaconda errors in Terminal and VS Code

Running into an issue I'm not sure how to resolve:
Installed VS Code, and used Homebrew to install Python 3.7, then installed Anaconda - was given an option to install it to my user home, and chose that option.
When I start up Terminal or VS Code though, I'm hitting this error - what have I likely missed?
Last login: Sat Dec 22 22:04:18 on ttys000
Traceback (most recent call last):
File "/Users/<myusername>/anaconda2/bin/conda", line 7, in <module>
from conda.cli import main
ImportError: No module named conda.cli
(Mac running Sierra)
I've attempted the following:
export PYTHONPATH="$HOME/.miniconda2/lib/python2.7:$HOME/.miniconda2/lib/python2.7/site-packages:$PYTHONPATH"
and the paths do appear to include Anaconda's paths. Python indicates Anaconda is present as well:
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
I'm sure I've missed a detail somewhere, but not sure what.
Likely this was a brute-force solution, but running anaconda-clean and then uninstalling anaconda2 and anaconda3, and finally reinstalling anaconda3 appears to have resolved this, since I don't actually need anaconda on Python2.7. I imagine the correct solution if I needed them both would be to set up additional environments to handle this.

Difficulty Setting Up Numpy for Python 2.7 on Mac OSX

I'm trying to run a script of mine using Python 2.7. When I run
python2.7
I get
Python 2.7.10 (default, May 25 2015, 13:06:17)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
When I try to run my script, I get:
Traceback (most recent call last):
File "bcp.py", line 1, in <module>
import numpy as np
ImportError: No module named numpy
So Python 2.7 doesn't seem to know about numpy. When I run
pip2.7 install numpy
I get:
Requirement already satisfied (use --upgrade to upgrade): numpy in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Cleaning up...
Any idea what's going on here?
Thanks!
This might be because you're using the wrong python distro on your computer. If you are using an OSX machine, there might be a python distribution in /usr/local/ and one in /System/Library/Frameworks. It seems like python2.7 might be linked to the one in /usr/.
Try
which python2.7
should locate which python distro "python2.7" is symlinked to. If you're symlinked to /usr/, just change it to the one in /System/Library and your numpy should work.

Cannot import matplotlib into Python 3

I am attempting to teach myself programming and keep running into problems downloading modules I need for basic tutorials.
My latest attempt has been to get the matplotlib module into my Python 3 environment. I have tried so many different install packages and so many advice I found on the internet that I cannot remember how I originally got the module. But it seemed that everything went well with the installation process.
I am using a Raspberry Pi2 throughout all of this with the Raspbian OS installed.
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import matplotlib
ImportError: No module named matplotlib
It may be possible that you actually installed the library for python 2. I would use pip to install the modules that you need. If you don't already have it installed, run this first command in the shell:
sudo apt-get install python3-pip
This program can be called with "pip3" or maybe "pip-3.2" in the shell.
To install mathplotlib with it, try running:
pip3 install matplotlib
or
pip-3.2 install matplotlib
That should install the Python 3 module for you.

ImportError: Twisted requires zope.interface 3.6.0 or later: actually it have been installed

I use OSX 10.9 + Kivy 1.9.1, but I have two versions of Python, Mac OSX self-contained 2.7.5 and another standalone 2.7.9 installed. Here are the details:
MacBook-Air:wzy$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
MacBook-Air:wzy$ python
Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
After having installed twisted with pip install twisted, I get the following error message in kivy with python 2.7.5, which does not happen in python 2.7.9
MacBook-Air:wzy$ kivy
>>> import twisted
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/twisted/__init__.py", line 53, in <module>
_checkRequirements()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/twisted/__init__.py", line 37, in _checkRequirements
raise ImportError(required + ": no module named zope.interface.")
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface.
MacBook-Air:wzy$ python
>>> import twisted
>>> exit()
I have even installed zope.interface several times and dedicate install target directory as one of the sys.path of kivy environment.
I do believe this is two version co-exist related, but how can I fix this?
When you do pip install twisted, you are installing Twisted into some Python environment, depending on which python executable you are invoking pip with. If you have a 2.7.5 environment and a 2.7.9 environment, pip install might be putting Twisted in a different place for each, depending on what other options you passed to pip. (You probably passed some other options to pip install because without privileges, by default, pip install will just fail. Did you do sudo pip install perhaps? Did you do pip install as an admin user into a homebrewed Python?)
The right way to do this is to only ever install Twisted into virtual environments. You can create a virtual environment with the -p option to virtualenv, which tells it which Python to use for that environment. Then, with the correct virtual environment active, you can pip install twisted and everything should work as you expect.
I had the same import error problem, providing another possible solution here:
I have zope.interface 4.4.2 installed, it turned out that my twisted version is too old. By upgrade twisted solved my problem.
pip install --upgrade twisted
Thanks Glyph,
Finally I find following simple command could directly fix this problem, because Kivy use his own virtualenv environment, but I do appreciated your kindly help.
kivy -m pip install twisted
Best Wish to you,

issue installing basemap for matplotlib toolkit multiple versions of geos?

I try to install matplotlib basemap toolkit for use in ipython but fail...
I followed instructions from matplotlib site intallation completes ok but issue as decribed below.
Changed location of GEOS_DIR like in comments of this question, again no luck.
I also looked at this
installed accordingly from the repos, not sure if I had to uninstall the manually installed version?
No solution yet, seems I already have a newer GEOS dev library installed...? In synaptic i have libgeos-dev 3.4.2 installed... does that conflict?
All installation and compiling from source when in python I get:
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpl_toolkits.basemap import Basemap
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/mpl_toolkits/basemap/__init__.py", line 37, in <module>
import _geoslib
ImportError: libgeos-3.3.3.so: cannot open shared object file: No such file or directory
>>> quit()
Seems it cannot find the right file..?
Now out of luck, anyone?
Ran into this problem with a manual basemap install so it apparently is still a thing.
My solution was to link libgeos-3.3.3.so into the /usr/lib/x86_64-linux-gnu directory.
me#here:/usr/lib/x86_64-linux-gnu$ sudo ln -s /usr/bin/libgeos-3.3.3.so
and poof problem solved. That particular problem anyways.
I ended up going to the directory where libgeos-3.5.0.so was, and linked libgeos-3.3.3.so to that file.
root#mypc:/# locate libgeos-3.5.0
/usr/lib/x86_64-linux-gnu/libgeos-3.5.0.so
root#mypc:/# cd /usr/lib/x86_64-linux-gnu
root#mypc:/# ln -s libgeos-3.5.0.so libgeos-3.3.3.so
It is not the best solution, but it worked for me...
I ended up copying the older version libgeos-3.3.3.so (used by the toolkit) into the folder /usr/local/lib on my linux mint distro...
Just in case anyone else finds this searching for a similar issue: I compiled basemaps from source and could not load it in python due to missing the same file. I'm not sure what went wrong with the libgeos installation, but I just installed libgeos 3.4.2 from Synaptic (or apt-get, whatever you prefer) and it took care of the problem.

Categories

Resources