I'm trying to use a game library called Cocos2d in python. However, I can't really import it. It's installed in one of python's lib directories, and when I import it, it's saying that it's not there. I know it has to do with pythonpath (provided in the IDE I'm using) but I'm not sure how to set it up. I've tried just adding the folder with cocos2d to the python path but it doesn't appear to work. The file's name is not cocos nor are there any files in the same directory with said name. Any suggestions?
Do you get an import error message ?
I don't know how you installed it but here are the steps I just did and which are working here.
Download cocos2d-0.4.0.zip from the official website
Extract it anywhere
Open a command-line in that folder
type python setup.py install
It even automatically installs pyglet.
Related
I'm new to Python, so I think my question is very fundamental and is asked a few times before but I cannot really find something (maybe because I do not really know how to search for that problem).
I installed a module in Python (reportlab). Now I wanted to modify a python script in that module but it seems that the python interpreter does not notice the updates in the script. Ironically the import is successful although Python actually should not find that package because I deleted it before. Does Python uses something like a Cache or any other storage for the modules? How can I edit modules and use those updated scripts?
From what you are saying, you downloaded a package and installed it using either a local pip or setup.py. When you do so, it copies all the files into your python package directory. So after an install, you can delete the source folder because python is not looking here.
If you want to be able to modify, edit, something and see changes, you have to install it in editable mode. Inside the main folder do:
python setup.py develop
or
pip install -e .
This will create a symbolic link to you python package repository. You will be able to modify sources.
Careful for the changes to be effective, you have to restart your python interpreter. You cannot just import again the module or whatever else.
I have Anaconda2 running smoothly on Eclipse's PyDev environment.
I have received a custom package from a colleague in the form of a folder with a "library" sub-directory that contains many ".pyc" files (which I presume are the function files) and a "init.py" file. But no matter what I do, I cannot seem to install the folder as a package.
I have tried everything posted here in the Anaconda Prompt (which I'm assuming was the correct way of implementing the instructions)
http://conda.pydata.org/docs/using/pkgs.html#install-non-conda-packages
but nothing worked.
I am very new to really working with Anaconda, Python, Eclipse, and PyDev (I have only written simple scripts with the default IDLE IDE in the past).
All I really want to be able to do is to use the package of functions given to me - even if they are not properly "installed", although that would be ideal. If anyone out there can help me with this I would be very grateful!
Pyc are precompiled files, you dont need them.
You should simply import package folder with
import folder-name
I recently started learning to use Python and built in modules such as Tkinter. However in order to finish the programme I am making, I need to use pygame to open a music file in the programme. I have what I am sure is the correct pygame files (see image) but I have no clue how to actually add it to be able to use when coding in Python. (Get the error that the module cannot be found).
If there is an intergrated Python module that will allow me to open music files then I would be interested in knowing if that is an easier method.
Pygame files:
In a web browser go to http://www.pygame.org/download.shtml locate the package that matches your environment and follow the instructions, (either download and run or type the command).
I am currently in the process of developing a module that I am using as a library to be imported in another project. I need a sane way that I can install this module in the python site packages in such a way that I don't need to reinstall it everytime I make changes to it. Currently, I am using sudo pip install --force-reinstall {BASE_FOLDER_FOR_MODULE}, but need to re run this command everytime I make any changes to the module code.
The little bit of info I've been able to find on the subject seems to indicate that while I can symlink the base folder for the module in the site-packages folder for my other project, that this may not necessarily be a good way to do it. Is symlinking the folder bad, and if so why? Is there an alternate (better) option?
Thanks
If the library is still under active development then consider adding it to environment variable PYTHONPATH. Directories in PYTHONPATH are appended to sys.path and are searched last when trying to find a module. Using PYTHONPATH means you only have to make minimal changes (set it in a config file source file or .bashrc file) for things to work. Once the library is finalised you can install it to the site-packages directory and remove it from PYTHONPATH.
I want to write a Python program that makes use of the lxml library (see http://lxml.de/). Of course I want to share my program with others and want to run it on different computers.
Now, I have a folder containing the lxml modules and a python file that does an import. Now, this import does not work and throws an Exception. You can see all the details and an overview in the following image:
http://www.qpic.ws/images/pythonprob.png
Searching for this error, recommendations were to put the path to the lxml source folder in to my PATH. But: I want the program to work on different computers without having to manipulate their PATHes/PYTHONPATHes! The module should just be referenced in a local context, that means, should just reside in a folder next to my program. I think, it does not really matter whether it is lxml or an other third party module collection.
Am I understanding something bitterly wrong or is there a simple solution to my needs?
System:
Python 3.3
• Windows 7
Thanks in advance!
Install LXML inside a virtualenv, and run your program from that environment. This will handle your PATH issue seamlessly. On different computers, you can build new virtualenvs and install dependencies.
lxml.etree is a compiled extension. It is not enough to put the lxml source folder into sys.path.
Try to download lxml-3.0.2.win-amd64-py3.3.exe from http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml, open the installer file with an unzip program, e.g. WinRAR, and replace the current lxml source directory with the lxml folder in the installer.