Using multiple development environments on the same OSX machine? [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I have recently got a new Mac (2015 MBP with 8gb ram) and I am trying to set up a development environment using 5 different stacks at the same time.
I've previously used a LAMP set up very similar to this - many of my old (client) projects are still based on a PHP MVC framework which uses Foundation and Libsass. While I don't want to make new projects in this way as I want to learn more, I still need to be able to maintain these other projects quickly and easily.
I then had some data projects in Python / Django. On my old mac I used a linux VM through Virtual Box for this (I don't yet own parallels etc).
I've also trying to learn to use the MEAN stack using gulp, browserify and playing around with React JS, as well as Meteor (which has it's own server too) and Ruby on Rails - and I want to do more development with these, but without losing the ability to work on my other projects.
My problem is that whenever I previously switched to using MEAN or Rails, I messed up my file watching / auto compiling for LAMP and Python and it took me ages to switch back. I really like how browserify works - e.g. to auto compile sass files / minify, and auto refresh the page, but I've hit problems with keeping my python server and lamp set up doing the same. I'm clearly doing something wrong and I'm keen to set this up properly with a clean install. All the tutorials I can find online refer to setting up individual stack environments, but I can't find much which refers to setting them up together.
I've decided that running a separate VM for each different stack would knock performance too much, and there are some things which I'd want to use on more than one stack like homebrew.
As such, my question is what are the specific advantages of using something like docker to keep things separate vs finding a way using something like homebrew to set up everything together on a single OS?
I'm aware file watching isn't so easy on docker with virtualbox - but I'm not sure whether to push through and find a work around or to use another way.
Thanks so much - I've been stuck on this for ages. I'm sorry if my question isn't very clear - I'm new to using node / meteor and ruby so I'm not sure the best place to start!

In my humble opinion the best solution by far is to use Vagrant. It's also free.
Not only that you can have a different environment for each project, but you can also script all the custom installations and configurations. You, or a colleague of yours, will be able to replicate the environment with a simple command, vagrant up.
A popular guide for setting up Vagrant for RoR development can be found here. However, contrary to that guide, I gave up using Chef in favor of a simple provision script. A guide can be found here.
Make sure to enable NFS though, else VirtualBox (Vagrant sits on top of it) will be quite slow.
While solutions like Cloud9 or Koding are surely useful for when you do not have access to your development machine, I wouldn't use them for day to day work.

Related

Understanding python development environments ide's, text editors etc [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
So today I spent hours trying to understand why the package I installed using pip install in terminal was giving me an "module not found" error. Which I know is a file path problem. After a lot of tinkering around I eventually pip installed the library on powershell. Like magic it works. To avoid these headaches in the future and to gain a deeper understanding of all things programming does anyone have a book or class they could recommend to understand the circus of ide's, text editors, file paths, kernals, interpreters, compilers etc. I have no idea where to begin and it's really hard trying to troubleshoot these issues when I've never been given any formal instruction on how all these things work together. Is this something learning a language like C would help me understand? FYI Or does this just take pain and years of experience to navigate. FYI I've only taken a few basic college level python courses.
No, this has little to do with the programming language. It’s about knowing your way around your operating system. As such it’s not a good SO question; perhaps you should try superuser or one of the OS-specific StackExchange sites.
But what helps is understanding the command line. When you run “pip”, you need to make sure that the program pip - which is just a Python script - is being run by the same Python interpreter that you’ll be using later when you try to import the module.
Basic advice: find all the “python” and “python3” executables on your system. Pick the one you want, or install a new one. Either way, make sure that the directory containing it comes before any of the others in your command search path, and both names (with and without the 3) are there and point to the same binary file. That way you always know what you’re getting when you run “python” at the shell prompt. Make sure you configure your IDE to use the same one, too. And instead of typing “pip”, type “python -mpip” so that you know it’s at least installing into the same environment you get when you type “python”.

How to quit Jupyter and become a better programmer? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am a self-taught programmer coming from a scientific (non-programming) background. I discovered Jupyter early after I started using Python. And although I greatly enjoy using it (Jupyter), I feel that it somewhat hindered my ability to think ahead and write code that will be easy to maintain and interact with in the future.
I inevitably end up with these endless notebooks that are impossible to navigate and mostly consist of redundant code. I then tuck away some of the functions into text files. Make a copy of the notebook, delete a bunch of cells, and start over. Until the notebook becomes unmanageable again, then semi-refactor, make a copy, prune cells, and so on.
I feel that at this point I should learn some basic software design principles and practices (like version control and code organization). Is there a course or a lecture series you can recommend that might help me with that? I feel that any advice from you will be helpful. Thanks!
This will help in learning version control from official Git Documentation
This will also help in Software development philosophies from wikipedia
Try sublime text editor. It is not an IDE but it is really good for coding and has a bunch of useful coding plugins. It is not free but has an unlimited free trial, in which you get all the features, and an occasional popup asking you to buy it. If you download it, you should also use some plugins to help you code python
I personally use these plugins:
Origami, Terminus, Kite & Anaconda
I f you don't like sublime or using a plain text editor, check out visual studio code, idle or thonny.
They are full IDEs (not code editors), and will thus have more features.
IDLE & thonny are beginner's IDEs and Visual Studio Code is a lot more powerful & complex
Now you have your Jupyter notebook replacement on to the version control
Instead of using git, use github. It is built on top of git, and is a lot easier.
If you don't already have a github account then create one. Now you have a version control system going. I am not going to go any deeper because i am not very good at github version control so check out this site

A Real Talk About Python Software Distribution [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know this is a hot topic and many people ask this question but I have the feeling I am missing something. What is the proper way to make a python application for end-users? Like, old-school offline .exe and so on. Many users won't touch the terminal/shell and to be honest most software these days is incredibly easy to install. What I know so far:
There are packages out there that can make your software ready for redistribution like
pyinstaller, cx_freeze, py2exe
I wrote my fairly complex software in like 2 weeks and going crazy for days over making pyinstaller work with my external packages. Is this pain normal? Have I made a mistake by relying on an interpreted language? Because compiling this stuff is mean business. In many other languages you just build the stuff within the IDE and there you go, built.
I am not concerned that my code might be decompiled, so what I have tried is to just create a .bat file with commands to execute my script with my virtual environment(!) python. Can I just manage to have the Python venv in place with my scripts without the user having to install it himself?
Or what is the "usual" way to do this? Use Cython? Or pyinstaller? Praying to the lord of code?
FYI: I am using Python 3.6.8, Windows 8 (don't you dare making fun of me :D) and Pycharm 2019.2
However thank you in advance for your time, regards,
Arjaan
There is no correct or established way of how to create an executable file for your Python project. It's opinion-based.
And how you want to distribute your software is entirely up to you. It can be source code, compiled, as a docker image, through Heroku One-Click deployment, debian package, all of the above, ???.
Having choices is nice. Some people need a really simple solution then Heroku or an exe file is nice. Some people are Docker power users, then a multi-arch docker image is nice. Some people want to modify the source code than having the source code is nice. Some people like debian packages and want your project with a systemd service file automatically enabled and started.
You might also not put into the work of getting docker/debian/heroku to work and just tell them a step by step guide on how to get it to run.
Debian and Heroku route might require some periodic maintenance due to the Linux distros updating to newer versions.
There is so much to it and it is an endless discussion where noone is right or wrong.

Python for Android [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I had a look at Kivy,but the problem is it needs a virtual machine to run apps. Isn't there a way where python codes are directly converted to java bytecode which can be run by android without any virtual machine? What are the merits/demerits in terms of performance?
May be something in jython which would help?
Try SL4A for running Python code directly on your device. It requires no compiling, conversion to bytecode or virtual machines.
More information Here
Also, you can download an IDE (I've used Eclipse, like in the tutorial you will find on the site), installed a plug-in, created my source files there and then uploaded them to my phone, if you're uncomfortable with writing code on your device.
This page has full instructions on how to package a Kivy app into an APK: http://kivy.org/docs/guide/packaging-android.html
I think some one mislead you a lot or you are confused about how things work with kivy.
I'll take this opportunity to try and make things a bit more clear.
Kivy can be used to build stand alone apk, only if you had searched kivy in google play. This link shows a list of apps that mention kivy, there are a lot more apps there that use kivy and just don't mention that. There is also a partial user maintained list you can look at. You can install the apps from google play and you'd see that they are self contained and don't require you to download anything extra.
There are very easy instructions available on how to build a apk in the link mentioned by #Marcins.
Every python code passes through the python interpreter usually pre-compiled to pyc, that's how python works even Java uses a virtual machine JVM, Android's implementation uses Dalvik VM. You can learn more about the VirtualMachines used in the languages like java/python here. The python interpreter/vm consumes the code and executes it natively, it doesn't convert it to java byte code.
if you need to make something that needs more performance then you can even use cython with kivy to get more speed.

Recommended Django Deployment [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.
Long version:
I'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better "deployment" of Django.
Currently I'm using Django through Tornado's WSGI interface with an nginx front-end on Debian Lenny. I'm looking to move into the Rackspace Cloud so I've been given quite a few choices when it comes to OS:
Debian 5.0 (Lenny)
FC 11 or 12
Ubuntu 9.10 or 8.04 (LTS)
CentOS 5.4
Gentoo 10.1
Arch Linux 2009.02
What I've gathered is this:
Linux Distributions
Debian and CentOS are very slow to release non-bugfix updates of software, since they focus mainly on stability. Is this good or bad? I can see stability being a good thing, but the fact that I can't get Python 2.6 without quite a headache of replacing Python 2.4 is kind of a turn-off--and if I do, then I'm stuck when it comes to ever hoping to use apt/yum to install a Python library (it'll try to reinstall Python 2.4).
Ubuntu and Fedora seem very... ready to go. Almost too ready to go, it's like everything it already done. I like to tinker with things and I prefer to know what's installed and how it's configured versus hitting the ground running with a "cookie-cutter" setup (no offense intended, it's just the best way to describe what I'm trying to say). I've been playing around with Fedora and I was pleasently surprised to find that pycurl, simplejson and a bunch of other libraries were already installed; that raised the question, though, what else is installed? I run a tight ship on a very small VPS, I prefer to run only what I need.
Then there's Gentoo... I've managed to install Gentoo on my desktop (took a week, almost) and ended up throwing it out after quite a few events where I wanted to do something and had to spend 45 minutes recompiling software with new USE flags so I can parse PNG's through PIL. I've wondered though, is Gentoo good for something "static" like a server? I know exactly what I'm going to be doing on my server, so USE flags will change next to never. It optimizes compiles to fit the needs of what you tell it to, and nothing more--something I could appreciate running on minimal RAM and HDD space. I've heard, though, that Gentoo has a tendency to break when you attempt to update the software on it... that more than anything else has kept me away from it for now.
I don't know anything about Arch Linux. Any opinions on this distro would be appreciated.
Web Server
I've been using Tornado and I can safely say it's been the biggest hassle to get running. I had to write my own script to prefork it since, at the time I setup this server, I was probably around 10% of Tornado's user-base (not counting FriendFeed). I have to then setup another "watchdog" program to make sure those forks don't misbehave. The good part is, though, it uses around 40MB of RAM to run all 7 of my Django powered sites; I liked that, I liked that a lot.
I've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it.
There's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache/mod_python isn't even an option, as I have very limited RAM.
Segue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though.
What I'm looking for is what you have seen as the "best" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.
Update your question to remove the choices that don't work. If it has Python 2.4, and an installation is a headache, just take it off the list, and update the question to list the real candidates. Only list the ones that actually fit your requirements. (You don't say what your requirements are, but minimal upgrades appears to be important.)
Toss a coin.
When choosing between two platforms which meet your requirements (which you haven't identified) tossing a coin is the absolute best way to choose.
If you're not sure if something matches your requirements, it's often good to enumerate what you value. So far, the only thing in the question that you seem to value is "no installations". Beyond that, I can only guess at what requirements you actually have.
Once you've identified the set of features you're looking for, feel free to toss a coin.
Note that Linux distributions all have more-or-less the same open-source code base. Choosing among them is a preference for packaging, support and selection of pre-integrated elements of the existing Linux code base. Just toss a coin.
Choosing among web front-ends is entirely a question of what features you require. Find all the web front-ends that meet your requirements and toss a coin to choose among them.
None of these are "lock-in" decisions. If you don't like the linux distro you chose initially, you can simply chose another. They all have the same basic suite of apps and the same API's. The choice is merely a matter of preference.
Don't like the web server you chose? At the end of the mod_wsgi pipe, they all appear the same to your Django app (plus or minus a few config changes). Don't like lighttpd? Switch to nginx or Apache -- your Django app doesn't change. So there's no lock-in and no negative consequences to making a sub-optimal choice.
When there's no down-side risk, just toss a coin.
If you want a lightweight alternative to Tornado, I'd suggest spawning. It's very good at code reloading and seems to have good performance - though of course best you try it out yourself.
I'd also recommend supervisord regardless of OS, for keeping Tornado or spawning instances up and running as well as any other essential services.
However 9 times out of 10 it's the database that's the bottleneck and choice of web server is not really going to impact site performance and scalability.
At the place I rent server, they have shaved down the Ubuntu images to bare minimum. Presumably because they had to make a special image anyway with just the right drivers and such in it, but I don't know exactly.
They have even removed wget and nano. So you get all the apt-get goodness and not a whole lot of "cookie-cutter" OS.
Just saying this because I would imagine that this is the way it is done almost everywhere and therefore playing around with a normal Ubuntu-server install will not provide you with the right information to make your decision.
Other than that, I agree with the others, that it is not much of a lock-in so you could just try something.
On the webserver-side I would suggest taking a look at cherokee, if have not done so already.
It might not be your cup of joe, but there is no harm in trying it.
I prefer the easy setup of both Ubuntu and Cherokee. Although I play around with a lot of things for fun, I prefer these for my business. I have other things to do than manage servers, so any solution that helps me do it faster, is just good. If these projects are mostly for fun then this will most likely not apply since you won't get a whole lot of experience from these easy-setup-with-nice-gui-and-very-helpfull-wizards
Personally I find one of the BSD systems far superior to Linux distros for server related tasks. Give OpenBSD or perhaps FreeBSD a chance. Once you do you´ll never go back.

Categories

Resources