Unable to compile python with pyglet in Ubuntu - python

In Ubuntu 15.10,Running
python3.4 sound.py
leads to this error:
Traceback (most recent call last):
File "sound.py", line 2, in <module>
import pyglet
ImportError: No module named 'pyglet'
I already installed pyglet with running this command:
sudo easy_install -U pyglet
resulting
Searching for pyglet
Reading https://pypi.python.org/simple/pyglet/
Best match: pyglet 1.2.4
Processing pyglet-1.2.4-py2.7.egg
pyglet 1.2.4 is already the active version in easy-install.pth
Using /usr/local/lib/python2.7/dist-packages/pyglet-1.2.4-py2.7.egg
Processing dependencies for pyglet
Finished processing dependencies for pyglet
I am confused about what is missing. I guess there are some confusion about different verions of python, pyglet or Ubuntu.

From the install output it seems that the installed version of pyglet goes to python 2.7 packages. From your command you are explicitly calling python 3.4 There might be a problem there. python 3.4 will not go to 2.7's packages to check for the module.
I suggest that you call the script using python 2.7. running just python is enough (the default env python)
You can take a look at this question on the installation of python 2 and 3 packages too

Related

Installing and importing Python Modules onto OS X

I've been trying for a couple of hours already. It seems IDLE can't find any third-party module. I am a Python beginner.
Here is some info about my system:
OSX version: 10.11.5
python version: Python 2.7, Python 3.4, Python 3.5
The initial installation using pip (among other methods) seems to work fine. When I repeat the installation, terminal responds with:
Requirement already satisfied (use --upgrade to upgrade): pyperclip in
./anaconda/lib/python3.4/site-packages
However, when I go to IDLE (Python 3.4) and try to import the module, IDLE responds with:
Traceback (most recent call last): File "", line 1, in
import pyperclip ImportError: No module named 'pyperclip'
I have read that it may have something to do with my PATH or some virtual environment. I’ll be frank, I’m not sure what to make of these as they seem beyond my current ability.
This inability to import modules is becoming an almost insurmountable roadblock to advancing with Python. If you can offer any ideas on what I can do or can ELI5 the solution, I am forever in your debt?
It seems you are using conda, but you are trying to install the pyperclip module with pip. Have you tried running conda install pyperclip?
As stated here:
Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side but they do not interoperate either.

Kivy for Python 3 on a Mac OS X

I was wondering if kivy supports Python 3 on Mac OS X systems. From the download page from the kivy official website, it seems that kivy-1.9.0 is available for Python 3.4 for Windows systems, but it does not seem to support Python 3 on Mac OS X:
Mac OS X Mac OS X 10.9, 10.10 (requires Python 2.7)
Kivy-1.9.0-rev3-osx.dmg (Mirror)
This seems a little but nonsensical, why kivy should support Python 3 on Windows but not on a Mac OS X? It could be because of the missing support of PyGame for Python 3 for OS X systems? Actually, there's a way to install PyGame for OS X systems for Python 3, so I do not understand why they do not fix this problem, if this is really a problem.
I have also tried to install it globally via pip3 using:
sudo pip3 install kivy
But I am getting the following error:
Collecting kivy Downloading Kivy-1.9.0.tar.gz (16.2MB)
100% |████████████████████████████████| 16.2MB 34kB/s
Complete output from command python setup.py egg_info:
Cython is missing, its required for compiling kivy !
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/tmp/pip-build-qt70t_44/kivy/setup.py", line 173, in <module>
from Cython.Distutils import build_ext
ImportError: No module named 'Cython'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-qt70t_44/kivy
You will need to build from source.
As a previous poster mentioned, you will need to get Cython installed.
To get the latest version, use
$ pip3 install cython
From there, you need to modify setup.py. Here's an example of how I did it.
According to the error message, you are missing the package cython:
Cython is missing, its required for compiling kivy !
...
ImportError: No module named 'Cython'
You should run pip install cython.
Then installing from source worked for me, by opposition to using pip.

Python module error - beginner

So I'm trying to import AppKit into my python project. I am using pyCharm, but every time I try to import, I get the following error message:
You are using pip version 6.0.8, however version 6.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting AppKit
Using cached AppKit-0.2.8.tar.gz
Collecting flask (from AppKit)
Using cached Flask-0.10.1.tar.gz
Collecting pygobject (from AppKit)
Using cached pygobject-2.28.3.tar.bz2
Traceback (most recent call last):
File "<string>", line 20, in <module
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3p/csss5m7x30ldjd4z0xt6sg380000gn/T/pycharm-packaging0.tmp/pygobject
I've tried running the command directly through terminal etc, and I have upgraded my version of pip to 6.1.1 as well.
Not sure if this is a really beginner's mistake that I am making, or if there is something wrong with my installs of pip or python.
Any advice would be great, thanks :D
First, "importing" and "installing" are not the same thing. Installing is how you get a PyPI package, and all of its dependencies, onto your computer, so you can use its modules. Importing is how you use a module that's already on your computer.
Second, there are two different things named AppKit, and I think you've gotten them confused.
If you're on a Mac, you're almost certainly trying to use import AppKit to get the PyObjC wrapper around the native Cocoa framework named AppKit. If you don't already have PyObjC installed (I believe it comes with Apple's built-in Python on OS X 10.8-10.10), you get it with pip install PyObjC, not pip install AppKit.
If you're on Linux or FreeBSD or similar, you may be trying to import AppKit to get the AppKit framework for building GNOME GUI apps out of HTML and JavaScript. (Although this is in early stages, so I don't think you actually do want it.) For that, pip install AppKit is what you want. But you may need to install some system packages for GNOME development first with apt-get or urpmi or whatever's appropriate for your system.
If you're on Windows or something else, neither one of these makes sense, so… hopefully you're not. :)

Pygame installation for Python 3.3

I am trying to import Pygame to use for my version of Python, 3.3. The downloads on the Pygame website only have Python 3.1 and 3.2. I cannot seem to be able to import Pygame though I thought I had it installed in the correct path. I have tried both the 3.1 and 3.2 Pygame downloads.
Is Pygame just not installed in the correct file path or is Pygame not compatible with my version of Python (3.3)?
I am running Windows 7 and here is the error:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import pygame
File ".\pygame\__init__.py", line 95, in <module>
from pygame.base import *
ImportError: DLL load failed: The specified module could not be found.
The main Pygame page seems to be rarely updated. You can download Pygame releases direct from Bitbucket at https://bitbucket.org/pygame/pygame/downloads.
If the solution from the Paul Vincent Craven's answer gives you "Python version 3.3 required, which was not found in the registry.", you have to download and install this version from the official download site:
Python 3.3.0 Windows X86-64 MSI Installer
If you are on Windows and have Python 3.3, open the download page on bitbucket. Download: pygame-1.9.2a0.win32-py3.3.msi
Then you can test if you have Pygame by importing pygame.
Every time I update my python verion (currently I'm working with python 3.3), I download a special build for pygame, from this adress. It has builds for many other packages, so I think it is worth to check it out.
I have had this problem also. Pygame has to be compatible with the version of Python and the type of computer you have. For example, if you have Python version 3.3.2, but downloaded Pygame version 2.7.1, the "import pygame" function will be impossible to use.
You need to download the version of Pygame that is equivalent to Python 3.3 from Bitbucket and Pygame is only available in 32 bit, so you need to make sure that Python is 3.3 32 bit. Download from: https://bitbucket.org/pygame/pygame/downloads
sudo apt-get install python-pygame
Raise some errors like 404 for some packages so
https://community.webfaction.com/questions/315/how-do-i-install-pygame
This link help full for me

How do I install Python packages/ wxPython on Mac OSX?

I'm very new to python and any non-basic computer functions in general, but I'm having a very basic problem and I can't figure out how to fix it. Any time I download a module from the internet and try to import it in python, I get an error message. For example, I just downloaded wxPython after being instructed to do so on a tutorial program for Python I've been using, and after entering "import wx" I got:
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
import wx
ImportError: No module named wx
How do I fix this so that python can find modules I download?
Thanks!!
Python version 2.7.3, and I downloaded wxPython from the download link on the website. Another thing I noticed: whenever I type in python setup.py install in the Terminal, I get:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
can't open file 'setup.py': [Errno 2] No such file or directory
Which seems to be another huge problem?
There are a few things you need to do to actually debug this:
Run python and check what version you are running.
type where python and figure out if you have multiple versions of python running at once.
With pip or easy_install, read the output to check where they are installing packages. It's somewhat likely that they are installing to the system-wide Python 2.6, as opposed to the version that you want it to be installed to (Python 2.7).
If you find any packages installed in the wrong place with 3, uninstall them with pip uninstall <packagename> and then specifically reinstall them to 2.7 with easy_install-2.7 or pip-2.7 install. If you don't see the option for easy_install-2.7 or pip-2.7, you need to install distribute and run its setup.py file with the specific version of Python you are using.
Make sure you are actually in the directory when running setup.py. For example, to install distribute, you need to cd into the appropriate directory to install.
Finally, a separate note: it's far easier to install packages with easy_install or pip, as opposed to downloading them separately. You should try doing that first. Again, distribute has more info.

Categories