How do I run code without the PyCharm IDE - python-3.x

Now that I am done with my project that was developed using PyCharm in a virtual environment, I need to distribute the code to my work machine; however, I am not certain on how to do this. Do I need to create a build of sorts so the code an run independently of the PyCharm IDE? Can someone please point me to the correct documentation on this crucial next step?

This really depends on what and how you're using the code for. If you just want to run it on your computer and it's a single file, you can open the command line/terminal and type python3 your_file_name and it will run the file (where your_file_name is the path to your .py file from whatever directory you're in). I assume you have python installed on your work machine, but if not, go here:
https://www.python.org/downloads/
If you have a more complex project or you want to deploy your code on a website or a server, these are probably good places to start.
https://www.jetbrains.com/help/pycharm/deploying-applications.html
https://docs.python.org/3.0/howto/webservers.html
EDIT: Added this as another useful link:
https://docs.python-guide.org/dev/virtualenvs/

Related

my pyinstaller executable is not opening on other computers besides mine

The last few days, I created a site, using wix, to use as a portfolio. I left all my projects there. My sister, helping me try It, downloaded one of them, but she could not open it
The first problem was solved pretty fast. My computer uses linux, and her's uses Windows, so I just had to use a windows computer to run pyinstaller on my project. It worked
Now, I managed to create the windows executable. I tested on my windows computer, and it worked. However, my computer HAS python, while her's dont. I think the error might be my venv (virtual environment). Maybe the python interpreter she is supposed to use to run the program is in the wrong directory?
Image of what you get, after downloading my project "FastGrid":
https://i.stack.imgur.com/PS77Y.png
(sorry for using external images, It's the only way I can make a good description the situation)
The only difference between her directory and mine is that her python files have a notepad icon. However, the extension is ".py", so I don't see how that is a problem. Unless somehow her pc is opening that with notepad, without using the python interpreter, and not executing the code properly.
Also, when I tried on my computer, my antivirus thought the file was a virus, and said It would take 80 minutos to verify It. I trusted the file and tried to open It, only to get a "You might not have permission to open the file" error. I refreshed the directory and It opened sucessfullt. The same happened to my sister (without the opening part, of course). She had this error, but later, when I tried again, It simply didn't run. No errors.
Again, I think the directory "venv" may be in the wrong spot, and that's why she can't open the executable, since the project may not be able to read the files. But, if that's the case, I don't know how I should modify that.
Also, here is my site, if you think that can be helpful. You can find my projects in the "blog" part
https://lvalencacomputacao.wixsite.com/website
Thanks in advance. If I wasn't clear, please, feel free to ask your doubts on comments. I'll do my best to make the post better
Edit: The image is the project for windows, but opened in ubuntu, that's why there is a ".exe" there.
does all of your computer have python, it could probably beacuse you are using a virtual enviorment, and need to activate it before entering the the exe. the command : .\venv\Scripts\activate to activate te asets in your python project, what was the difrent from your sister computer and all of the computer, i could help you
Everyone, the problem is solved. My sister's pc is probably the one at fault, here, since the program worked in every computer I tried besides her's.
Thanks

How to edit google app script outside of the browser, e.g., in emacs or vim?

I want to edit GS (google app script) files in a decent editor (Emacs or VIM) and keep it under git, so I need to be able to install it to run it.
Right now I copy the whole file and paste it into the code window in the browser, which is clearly suboptimal.
I wonder if there is a way to do it.
For some reason, Edit With Emacs does not work with the script editor.
The google apps script
Importing and Exporting Projects guide details using the Drive REST API
Note: Import/Export of scripts is limited to Standalone scripts
Only standalone scripts can be imported or exported. Container-bound scripts cannot be accessed through the Google Drive REST API.
This Google repo details how to work with scripts in a local dev environment
It uses node-google-apps-script which is really all you need to import/export your script project to a local machine and back to Google
It is a little bit of work setting it up; there are quite a few steps to work through
Despite this question is a bit old, I consider it could be useful for someone still wanting to edit App Scripts outside the browser.
There is a tool named clasp which aims to provide a way to edit an app script project in a local environment: https://github.com/google/clasp.
You just need to install via:
npm install -g #google/clasp
And enable the Google Apps Script API: https://script.google.com/home/usersettings
To use it, you should include a package.json via npm init (tested with version 2.4.0) and then make:
clasp login
clasp clone "projectID"
Afterwards, you could edit the files with your favorite editor. Finally, you could push the changes via:
clasp push
For more information, please check the repository of the project, pointed out above.

Correctly set up Valves Source SDK 2013 on Linux

I just try to set up Valves Source SDK 2013 for Linux but I need to say that I find the wiki + documentation rather confusing and partly heavily outdated (Windows-only instructions, only for GoldSrc / pre-20XX SDk etc.).
I hope that someone who already has gone through the hassle can supply me with some hints on how to correctly set up the system.
I tried to use some Windows-specific instructions to understand the system but some are highly platform-specific.
So here is the current status (I based what I did on this wiki page: Wiki: Source SDK 2013:
The source of the SDK SDK 2013 from GitHub is cloned to
~/Git/source-sdk-2013/
the SDK Base 2013 installed via Steam and the steam-runtime to
~/working/steam-runtime-sdk_2013-09-05/
I was not sure whether there is a specific path I should put the steam runtime into so I just put it into my self-created working dir.
# Create a Multiplayer sample project
export SDKROOT="~/Git/source-sdk-2013"
bash $SDKROOT/mp/src/creategameprojects
bash $SDKROOT/mp/src/createallprojects
# Setup Steam Runtime
export STEAMRT="~/working/steam-runtime-sdk_2013-09-05/"
cd $STEAMRT
# Choose all build targets (i386 + amd64) and download these
./setup.sh
# Set current to target to the same as host machine (ie. amd64)
./shell.sh
# Compile the actual game
make -f $SDKROOT/mp/src/games.mak
I have not yet touched any source files as there's plenty of sources already supplied. I just wanted to confirm having a working toolchain set up
This all compiles fine but in the end the script wants to chmod the client.so and server.so but claims "not found" – but it sadly does not provide any information where it searched for them. Actually these are existant in
$SDKROOT/mp/game/mod_hl2mp/bin
and even marked as executable (-rwxr-xr-x).
So I just ignored this and hoped for the best. The next line to me sounds a bit strange:
At this point you should have client.so and server.so files to load with the Source SDK Base 2013 of your choice.
So I should be able so load the files with "the Source SDK Base 2013" (of your choice?!? Valve is the only one providing it O.o). How am I supposed to do that? I have not found any hint whatsoever for that, sadly.
But they hint me to the README.txt of the steam-runtime which tells me to do this:
run.sh ./MyGame
But where's the executable? I only have .so's
And this is the point where I currently am. I'm quite confused as I have many questions now:
Why do only the Linux users need to download the steam runtime? What if I want to not ship via Steam?
Is that chmod failure a script failure or a mistake in my directory setup?
How do I load these libraries via the SDK Base
Where is the binary? I'm quite confused here...
Have I overlooked something?
I appreciate any hints or links to resources, maybe explanations when I just were to dumb to understand what they mean :P
EDIT: Actually there is a GitHub repo for the steam-runtime too (GitHub/steam-runtime) – why is the download so outdated, the git repo has some updated stuff going on. Which should one choose?
With the help of a friend I didn't expect to be able to answer this (he didn't know about Linux but we could figure it out) I could solve it faster than expected.
To "load" the game via the Steam SDK Base just append the -game parameter and point it to the directory with the gameinfo.txt (ie. $SDKROOT/mp/game/mod_hl2mp/) in it.
Alternatively just copy the contents of this directory to
~/.local/share/Steam/steamapps/sourcemods/$MYSOURCEMOD
where $MYSOURCEMOD is how you want to call it (do not use spaces). Then add a steam.inf file in that dir with following content:
appID=243750
ProductName=$MYSOURCEMOD
PatchVersion=1.0.0.0
After a restart Steam will be able to find the sourcemod.
I'm not quite sure what the "steam-runtime" thingy is but I suppose it is to set up the build environment (to use a custom gcc etc.) as this is how the scripts look like. I'm not sure why you should run the game via the run.sh in the bin/ subfolder of the runtime instead of via Steam or via the parameter one the Source SDK Base but maybe someone can enlighten me here.
The archive one shall download is only a downloader/configurator for the steam-runtime hosted on GitHub.

How do I launch an application from a .sh script?

Help me please with a bash script of a few lines.
I have a MyApplication executable in some folder, and I need to make a launcher script to call that application from it's folder when I click it from a grafical interface.
(I need this because I need my application to be launched from it's folder, so that Qt::currentPath() will return the current folder the executable is in)
Please help me, I just had to power off my linux machine two times in a row, I made fork bombs instead of launchers :(.
P.S. I'm a linux newbie, trying to figure out scripting.
EDIT
More about my current problem: Qt how to open a file in current dir ? or what's wrong with this?
Details: MyApplication is a GUI project compiled in Qt-Creator. It uses .xml files for storage. If I cd manually to the folder the executable is in, and run it, everything works fine, the application knows the path to the .xml files (current directory). But, if I just click the icon of the application it launches from $HOME, and my application is not able to find those .xml files.
That's why, I suppose, I need a .sh launcher, to call it from it's directory when I'll click it.
If its a graphical application, any sort of link will do. That works fine for me, unless you have something I'm not aware of, in which case please explain more.
Ps, fork bombs are limitable - http://forums.debian.net/viewtopic.php?f=10&t=44480&start=0

Running a Qt application at startup

I wrote a Qt application that is going to run on Linux. It supposed to run at startup.
It's supposed to run on every Linux- Suse, RedHat etc.
What script should I write and Where to put it?
I don't know how to write scripts at all, so I would appreciate it if you will attach an example.
You need to create a desktop entry file for your application (see here) and to put it in user's $HOME/.config/autostart directory.
Any desktop entry file in that dir will get executed when a Window Manager starts up (see here).
To do this, usually you'll need to create your desktop entry file by hand (that's it, not via C++ code/script) and to just install in that directory via C++ code.

Resources