I use Kodingen.com to test python scripts. I would like to install new python packages on Kodingen. I know I can use the 1-Click installation of the App-Store to install new packages from ohloh.net. When I install a package, it create a new directory in httpdocs folder. And then? How to setup the python package to use import in my scripts? Is it possible for a user to do it?
I'm looking for the complete procedure. As example, we can use PIL (Python Imaging Library). How to install it?
For information, Kodingen use a linux server.
I asked a similar question but this one is a more general question about the python packages install.
hey thammas, we are working on kodingen v1.0 with which you will be able to use your own server connected to your account. then you can install anything and use it freely.
but now, kodingen provides shared hosting account that doesn't enable anyone to install anything. same applies to ruby gems. but we will make this possible very soon.
just to reiterate, kodingen is able to run python/perl/php scripts, just not external/custom libraries until we give you your own servers. hope it clarifies.
Related
I've recently been looking into emulators (and purchase) of a Casio CG50 Calculator. It has an option to run python, and I think runs on micropython. It obviously doesn't have pip, so I was wondering if there was any way to import external modules and packages, maybe by installing the git repo for a package? Thanks.
Download link for Casio Cg50 Emulator
When you need to manually install a library, you can just copy the file from the Repo to your project.
If I use a module such as tkinter, would somebody need to have that module installed as well in order for my code to run on their machine?
Definitely. You can use virtual environments or containers to deliver required packages or have a requrements.txt or similar to install the dependencies.
python comes with a number of standard modules pre-installed, if the other person is running python (the same version of you) then he/she won't need to install anything, it will just work, that's the case of tkinter. But if you use external packages that you installed to run your code, for example celery, then he/she will need to do the same thing.
If you gave your code to someone to run, they would need to download the same modules, unless you also sent the environment too. The only way I know around this is to freeze your code where you would create an executable. I've used cx_Freeze and pyInstaller and haven't had any issues but it also depends on your needs. You can find some more information through here:
https://docs.python-guide.org/shipping/freezing/
Hope this helps!
In your running environment do a, this file you add to your repo
pip freeze > requirements.txt
When people clone your repo, they only have to do a:
pip install -r requirements.txt
and they will install exactly the same pypi modules you have.
With virtualenv you can isolate a python environment to each project, with pyenv you can use different pythonversions withing the various environment also.
The server that I am using has an older version of python installed, and I am unable to install packages. Is there a workaround to importing python modules? If I can create my own module and append the directory to be able to import the newly created module, then I am assuming that I should be able to do the same for already built packages. I just need to know how I would be able to install what is required for numpy and then import it using a similar method as when creating modules.
I would recommend that you find a machine to install the same version of Python to match your server. Perform the pip install from that stand alone machine. Do some level of testing to make sure that the code with run with that version of Python and everything is happy. Just the other day I found out the hard way that TensorFlow would now work on the latest Python.
The libraries are being installed for me under c:\users\<profilename>\AppData\Local\Programs\Python\Python36\Lib\site-packages So you could then copy that over to the server.
I found this link that is saying the same thing.
https://superuser.com/questions/943980/is-it-possible-to-install-python-packages-without-a-direct-outbound-network-conn
Good Luck with it.
I'm currently launching my website and I want my Python script to be run. However, it does not work when I run it because it depends on 5 libraries. How do you link them to your code?
For example, I use pymysql to write data to my host's database. However, it does not recognise pymysql.
Is there a way to download all of the packages once on the server and then being able to access them? How to link to them in the code?
Many thanks !
There are many ways to do this, the easiest way is probably to use pip freeze > requirements.txt to get a list (requirements.txt) of the dependencies that you have installed for your project (which, if you're running under a virtualenv, is only those installed for your project).
If you have installed multiple libraries for your interpreter that you don't need, you can remove them from the list, or create the list manually.
You can make pip install all the libraries again on your host by doing pip -r requirements.txt.
The best way is to package your project and deploy it on your remote server.
The best practices nowadays is described in “Packaging and Distributing Projects” from the Python Packaging Authority
You can follow the Sample Python project available on GitHub.
Another way is to create a library or an application using a project template. One of the famous ones is cookiecutter-pypackage from Audrey Roy Greenfeld Cookiecutter.
This is the info you're looking for:
https://www.namecheap.com/support/knowledgebase/article.aspx/9587/29/how-to-run-python-scripts
They give two solutions - the cPanel solution and the SSH solution.
If one creates a useful Python package, how/where does one publish/advertise it for other people to use?
I've put it on hithub, but even Google does not find it after a few weeks.
The package is neat & complete, I made it for my personal use and would be a shame not to share it with others :)
Here is the PyPI guide. https://python-packaging-user-guide.readthedocs.org/en/latest/distributing.html
PyPI is the place for putting your Python packages up for others to find. The built-in tool pip references it to install packages for you, and at least one IDE uses pip in the background to give you a GUI for doing this. (PyCharm)
So, to make the package available to a pip install, you have to register it in the Python Package Index (PyPI): https://pypi.python.org/pypi
There's also the test environment, where you can upload your packages to test if your setup is ok before going to the real deal: https://testpypi.python.org/pypi
You create an account in one of the servers and will be able to upload your package. But, before that, you will have to build your package using setuptools. Here's the documentation for packaging and distributing: https://packaging.python.org/distributing/
The proccess can be little boring, so I wrote a little tool to make it simpler. Maybe it's of some use to you: https://github.com/hugollm/foster