Creating a Python Project using Atom - python-3.x

I m trying to create a python project in Atom IDE. I downloaded and installed Atom and also some package like project_manager.
I am finding it extremely hard to get going.
My project would have a few python files in the code folder. Some data files in the data folder, etc.
How do I start this in Python. I goggled this as well but still finding it difficult.
P.S. I know how to create python files and run them using IDLE. Want to do my work in a more structured manner by creating a project and then being able to compile and run my files fast and easily.
Regards
Bonson

Related

I want to be able to run my Python through Atom like i have been able to do on my phone with dcoder

So Im very new to programming and computers in general... Over the last couple months i have learned everything i know on my phone using Dcoder with android. I have been searching for a program that is similar but on a laptop that can compile my .py files. So i downloaded Atom and have installed atom-python-run and other packages to run my code through the terminal (even though I would rather it compile like on Dcoder) but it says that python is not a file... so i changed the path in the control panel to the right folder but now it says no pyvenv.cfg file... in cmd it doesnt work when i type in python but it works when i type in py... idk
honestly if anyone knows how i can get a program like dcoder on my laptop i would greatly appreciate it... i am way more familiar with phones than i am with laptops... but im trying to learn.
I have tried everything. This is my last hope before giving up
error message one on atom: windows cannot find python make sure you have spelled it right
is there anyway to just get it to search for py????
If you want to run python using the Atom editor you must first load python into Atom. This is simple. Go to this site and install the extension 'laungage python'. Then search for and install the package 'Script'. Script will successfully run your python files. Run Atom and enter your python file. Then go to the packages menu and click on Script. I haven't been able to get Python Runner or Code runner to run my python files, only Script.
Dcoder has a web app also at https://code.dcoder.tech, Dcoder uses cloud storage, makes it easier to switch between phone and laptop to code when needed.

How do I run a .py script?

I just started learning Python last week to automate some stuff I do (thanks to automatetheboringstuff.com). Assume I know nothing about programming. The only thing I know is HTML and CSS.
I created a simple automation workflow already and I want to improve not the code (maybe in the future because it's not yet finished) but how I can maintain my setup/program on two laptops -- Both Mac OS running on High Sierra.
I have a .py file that contains my automated workflow. I don't know where to place it. It currently resides in my Dropbox so i can use it on laptop1 and laptop2.
I also created a virtualenv for each machine and did the requirements.txt thing as well (just to prep for the future). The directory is on both username/python/project_name.
I read in some posts that these files and other resources can exist anywhere whether inside each virtualenv or not. And that it's just a preference. I also read that the virtualenv itself isn't recommended to be placed inside apps like Dropbox (that's why i separated it on each laptop).
I switch between both laptops frequently. The environment which contains the packages doesn't really concern me that much when switching. It's the other files that is bothering me. For example, there's an image I need, this has to be available on both laptops so my solution to this is to have a Resources folder inside Dropbox as well. It currently looks like this:
Dropbox
Projects
Project 1 files (images, etc.)
Project 2 files (images, etc.)
Workflows (this would contain my completed .py files)
I read some stuff about the virtualenvwrapper, but haven't looked at it yet. Maybe in the future when i do have more projects to manage. Because right now, it's just this one.
Lastly, I noticed that every time i open up Terminal and activate my virtualenv, the file directory is in Users/username
How can i set it to default to Dropbox/Projects/project_name? I always have to set it using the chdir(). That way, when i do have multiple projects (and virtualenv) i don't have to worry about where the files load/ save.
Finally, how do I run the .py script? If i open the IDLE, open the .py file there, and use f5, it runs properly. But as far as I know, that doesn't look into the virtualenv i setup. Is that correct?
I tried right-clicking, then Open With > Python Launcher the .py file. and i'm getting an error saying there are no modules found. It seems it's not loading the right virtualenv. So there must be something wrong with the file i made.
Then I read about the #! you place at the beginning of the .py files but i don't understand it. Can someone explain that further? Is that why my file isn't loading properly?
Thanks for helping out!
You can run .py scripts from the command line using:
python test.py
That tells terminal to run test.py in the python interpreter and send the output to your terminal, just like when you run it in the IDLE. If your .py script is not in your current directory and you don't want to change directories, you can access it using it's absolute path:
python /Users/username/Dropbox/Workflows/test.py
As long as you have already activated your virtualenv, it should run your script using only the libraries you have added to your virtualenv. Also, once your virtualenv is activated, you can move around directories using "cd" and it will bring your virtualenv with you.

Setting up an automated pdf comparison on a server

Documentation is generated for every new build. I want to automate the process of comparing the new pdf with the old one and outputting the differences onto a text or image file. I also have the option of comparing large HTML folders or chm files(which is complicated as they are compiled files). How should I go about doing this? (I am looking for freeware Python tools)
I have looked into pdf-diff, a Python tool that does exactly what I want. But since I am working on a windows machine with no visual studio, when I try to install it using pip, I get the error "Unable to find vcvarsall.bat".

Python Compilation to .exe

I am new to python and need to compile it into .exe version. My question is when a py script is compiled into .exe does it mean it cant decode anymore?
Our goal is make python scripts safe when deploying to client servers as we dont want them to get our source code using the .exe.
No - a compiled piece of code is compiled into another language (byte code) - you can not actually read the source code.
Do have a look at this though...
A savvy user who has this .exe version could extract the .pyc (byte code) and then break that down using a python decompiler like Uncompyle to get it pretty much back to source code. Thus there is a way (and a chance) of the python source code (close to it) getting extracting from your .exe version.

Trying to open a python file in IDLE. Instead, a pycache folder is created. How do I fix this?

I have a number of python files with .py extensions that I was working on, closed, and tried to come back to later. When I tried to open them by right clicking and selecting “Edit with IDLE,” instead of opening a pycache folder was created.
I have a work around in which I go to edit the file with Notepad++, copy the text into a new python editor, delete the old file, and resave the new file with the same name. My research has turned up questions related to pycache and IDLE, but none specifically addressing the issue. Has anyone encountered a similar problem/know how to solve it? I’m running Python 3.5.2 on Windows 7.
What did you name the .py file as? If you named it something like "string.py", Python might interpret the file as one of those in the "Lib" folder. Why you can resave it with the same name and have it working afterwards is anyone's guess. I suggest just renaming the python file to something else.
I developed the bad habit of writing/editing python files with IDLE from watching intro videos when I was still relatively new to programming. I have since learned that file editors like Sublime or IDE's like PyCharm are a significantly better way to go and would highly recommend anyone reading this.
I had a similar issue. When I clicked "Edit with IDLE 3.6", it would create a "pycache" folder and not open the python file on IDLE.
I found a Reddit thread that gives an explanation here.
The reason the pycache folder is created is as follows:
When you import a module, Python stores the compiled bytecode in that
directory so that future imports can use it directly, rather than
having to parse and compile the source again. It does not do that for
merely running a script, only when a file is imported.
No such folder is created for the standard library, as the standard
library is pre-cached when you install Python
I was importing Python's "random" library, in another python file (placed in the same directory). So the issue was solved once I deleted that file.

Resources