I need to use the Sybase Python module but our SA's won't install because it's not in the repo's. I've downloaded it and placed it on the box and would just like to 'import' or 'include' the module without installing it first. - Is this possible? From the looks of it (Sybase ASE) it needs some type of compilation before use. Is it possible for this type of work around?
If you can get Sybase to use a virtual environment (I know nothing about Sybase, sorry), perhaps you could install the module using virtualenv, which generally doesn't require root access or SA approval.
From the sybase documentation it looks like compilation is required, and Google tells me that it's not available in the easy_install repos either.
It may be easier to do a little social engineering (cookies anyone?) to get the modules installed for you. I don't know what your work environment is like, but if you really need the python Sybase module to do your job, either 1) the SA's should be installing it anyway, or 2) you need to be using something different.
You could always try writing a python script that does the d/l and install automagically and give it to the SAs so they don't have to worry about the "difficulty" of doing something besides apt-getting.
I don't know about the virtual environments, though - that might be an ideal avenue.
Assuming you meet the prerequisites for compiling, untarring it and then running:
python setup.py build_ext
should produce a sybasect shared object. Copying this file and the Sybase.py file somwhere onto PYTHONPATH might just do it for you.
Related
I'm making a program that uses PyMySql and I'd like people to be able to run my program without going through the manual installation of PyMySql, is there a way I can achieve that?
I've already tried compiling to .pyc but that doesn't seem to work, in fact when I uninstall PyMySql it doesn't work anymore.
PS: There probably are better languages to do that but it's a homework assignment for school and can't use anything but python, also sorry for my bad english
Since PyMySQL has MIT license, you can redistribute it without any legal issues and also is a pure python implementation so it doesn't matter on which operative system it runs.
Just go to your python library folder and look for the module folder and copy it to your project folder, after that you can uninstall and python should be able to import it from your project folder and you just need to send your assignment with the module included.
The python library folder varies depending on your operative system, you can look at this answer on how to find the module location.
Use cx_freeze, pyinstaller or virtualenv.
Or copy code and put in your. Read python import
I have a simple python shell script (no gui) who uses a couple of dependencies (requests and BeautifulfSoup4).
I would like to share this simple script over multiple computers. Each computer has already python installed and they are all Linux powered.
At this moment, on my development environments, the application runs inside a virtualenv with all its dependencies.
Is there any way to share this application with all the dependencies without the needing of installing them with pip?
I would like to just run python myapp.py to run it.
You will need to either create a single-file executable, using something like bbfreeze or pyinstaller or bundle your dependencies (assuming they're pure-python) into a .zip file and then source it as your PYTHONPATH (ex: PYTHONPATH=deps.zip python myapp.py).
The much better solution would be to create a setup.py file and use pip. Your setup.py file can create dependency links to files or repos if you don't want those machines to have access to the outside world. See this related issue.
As long as you make the virtualenv relocatable (use the --relocatable option on it in its original place), you can literally just copy the whole virtualenv over. If you create it with --copy-only (you'll need to patch the bug in virtualenv), then you shouldn't even need to have python installed elsewhere on the target machines.
Alternatively, look at http://guide.python-distribute.org/ and learn how to create an egg or wheel. An egg can then be run directly by python.
I haven't tested your particular case, but you can find source code (either mirrored or original) on a site like github.
For example, for BeautifulSoup, you can find the code here.
You can put the code into the same folder (probably a rename is a good idea, so as to not call an existing package). Just note that you won't get any updates.
I have the following problem. I need to distribute our own version of python with some magic in it. In order to do this, the process is the following:
I build the python interpreter (on a redhat linux)
install it somewhere
tar.gz the whole thing
when it's time to make the user-package, unpack the tar.gz into the directory which will become the user package
tar.gz the user package directory
put the tar.gz on the web
This is the method I have to use. Good, bad? I don't know, I have little experience as a packager, and in any case I can't propose a change. This is the way they always did.
It turns out that when the user unpacks this tar.gz on suse, and tries to run the python setuptools (which has been installed together with python), the hashlib module raises an exception. What I found out is that building python on redhat, the python configure script finds the openssl library, which in turns makes it skip the building of the shamodule.c, md5.c and so on, and compiles hashmodule.c to attach to the openssl library. apparently, the openssl 0.9.7 on suse and the 0.9.8 on redhat are somehow different, meaning that, for some reason, the _hashlib module, when imported on suse, raises an import error, leading hashlib try to import _md5, _sha, _sha256, which are not there because on the redhat there was no reason to compile them (since openssl was jolly good there).
Does anyone know how to solve this problem. As I said, my experience as a packager is the bare minimum, so any hint and proposal are welcome, and I will try to deploy it as much as I am allowed by our legacy.
Does anyone know how to solve this problem.
You can't, really. If it's not the OpenSSL library that's a problem, it could be the C library itself, or some other critical component. Your best solutions are either:
(A) Build a version of Python for each operating system you wish to support, or
(B) Rework your code to use the native system Python on each platform.
Your alternative is to create a completely self-contained build environment so that when building under RedHat you're not using the system OpenSSL library, but are instead using one that you built yourself. This will work for just about everything other than the C library, but it can be tricky to set up. The idea is to minimize the relationship between your package and the system libraries.
If you're only supporting RedHat and SUSE, you could conceivably pursue option (A) by crafting an appropriate spec file and building binary packages for each platform. This would be a nice way to package everything up.
You should consider distributing a source RPM of your version of Python, rather than a binary tarball. You can take an existing Python release and repackage it with a patch of your changes. There's more detail on how to do this in the RPM Book.
I'm new to python and I'm writing my first program. I would like after I finish to be able to run the program from the source code on a windows or mac machine. My program has dependencies on 3rd party modules.
I read about virtualenv but I don't think it helps me because it says it's not relocatable and it's not cross-platform (see Making Environments Relocatable http://pypi.python.org/pypi/virtualenv).
The best scenario is to install the 3rd party modules locally in my project, aka xcopy installation.
I will be really surprised if python doesn't support this easily especially since it promotes simplicity and frictionless programming.
You can do what you want, you just have to make sure that the directory containing your third-party modules is on the python path.
There's no requirement to install modules system-wide.
Note, while packaging your whole app with py2exe may not be an option, you can use it to make a simple launcher environment. You make a script with imports your module/package/whatever and launches the main() entry-point. Package this with py2exe but keep your application code outside this, as python code or an egg. I do something similar where I read a .pth text file to learn what paths to add to the sys.path in order to import my application code.
Simply, that's generally not how python works. Modules are installed site-wide and used that way. Are you familiar with pip and/or easy_install? Those + pypi let you automatically install dependencies no matter what you need.
If you want to create a standalone executable typically you'd use py2exe, py2app or something like that. Then you would have no dependencies on python at all.
I also found about zc.buildout that can be used to include dependencies in an automatic way.
I am having problems getting python/django to connect to a MySQL database. The error message is basically "Error Loading MySQLDb module: No module named MySQLDb".
This is a fresh install right off python.org, so I assumed that it would have the MySQLDb module included, but it does not seem to. I also can't seem to find the module or how to install it, except in some sleazy looking parts of the net.
Is there a central point for getting this module? Why isn't it in the standard install? Can someone point me to a tutorial or some such to get this module installed?
Newbie in python, MySQL and Django.
Thanks for help.
I believe http://pypi.python.org/pypi/MySQL-python/ is the Python module you need. In general, when looking for Python modules, http://pypi.python.org/ is where you should start (people will refer to it as either PyPI or "the cheese shop." If setuptools is installed (it may be already) then you can run easy_install MySQL-python.
As far as MySQL is concerned, you'll need to install that separately from a likely-looking package on http://dev.mysql.com/downloads/mysql/.
this is how i handled the issue on Fedora13:
you can get the module here: http://sourceforge.net/projects/mysql-python/
download to a convenient directory
read the README file
build the module, according to the instructions in the README, keeping in mind to use the version of python you are planning to use as an interpreter (2.6 for me). if there are more than one version of python, simply using 'python' will probably alias you into a particular version, which might not be the one you want.
after the build is complete, the .egg file will have been created and landed in a 'site-packages' directory associated with the version of python which was used for the build.
then, ensure that the .egg file created (you can see the install path in the output from the install) is placed on your PYTHONPATH
that did it for me, anyhoo...
good luck!
JR