How can I run my program without using PyCharm? - linux

I have to finish the program on which I worked six months. This is my very first program.
I designed with PyCharm and I have a database and several module.
How can I run my program without using PyCharm?

Based on the fact that you are working on this project for the last 6 months, my guess is that you were running it through PyCharm. In most cases when you run your project through PyCharm you can see that on PyCharm "Run" console the first line logged is something like that:
/path/to/setup/bin/python<version> path/to/your_project/file_contains_main.py --argumnent1=value1 --argumnent2=value2...
Scenario 1
If you see something like that, then you can copy your project in a system that has python installed and run the same file_contains_main.py as below:
python path/to/your_project/file_contains_main.py --argumnent1=value1 --argumnent2=value2...
Some more details for Windows here and for Linux here.
Scenario 2
If you do not see the command above logged in PyCharm then you may find this solution more appropriate.

Related

Linux Ubuntu how to start standard application scribus from python eclipse anaconda

I edited my question, hope it is described better now.
I am working on a software that gives me a nice PDF with lots of matplotlib graphics, depending on the data I get.
So think of a database of pages and then the software decides which pages are chosen and filled with changed images, The text stays the same.
So for instance for data1 I get page1-4 and page7 and page 9. For data2 I get page1-4 and page6. Saved as PDF. I am doing this manually with Quark which needs to be changed. I hope I can figure out the scripting to do so.
But for starters I cant start scribus from the developing enviroment. Eclipse Anaconda on Ubuntu.
import subprocess
subprocess.run('scribus')
works fine in terminal, but gives me an error in Eclipse which I cant figure out.
File "/home/b256/anaconda3/envs/test/lib/python3.7/site.py", line 178
file=sys.stderr)
^
SyntaxError: invalid syntax
This seems to be some Python 2 error in the site.py file
???? Is this some anaconda python path error ??
It's not really clear to me, what you want to achieve, but you're welcome to have a look at a script of mine:
https://github.com/aoloe/scribus-script-repository/blob/master/imposition/imposition.py
This is probably a bit more complex than what you are trying to achieve:
the script gets started from the terminal,
if it notices that it has not been started from inside of Scribus (the exception on import scribus)...
... it starts Scribus with itself as the Script to be run.
the script runs again, this time from inside of Scribus...
... now there is no exception when importing scribus and the body of the script runs.
Of course, it's simpler if you start a script that launches Scribus with other scripts.
For you the most important line is probably:
call(['scribus', '-g', '-py', sys.argv[0]] + arguments + ['--', file])
It's starting Scribus from Python
with as little GUI as possible (-g) and
launches the script sys.argv[0]
with a few arguments and
after the -- tells Scribus what file to open.

I have tried many methods and I couldn't find solution. So how to convert Python file to executables?

Python : 3.5
PYinstaller : 3.5
Win64
cx_Freeze : 6.0
According to the above information, I have tried to convert Python project to exe but it does not work.
First I have tried pyinstaller but the process throw some error:
After that, I have tried cx_Freeze and it works, but the exe are working on some computer but not on every computer that have same platform.
I don't know what I can do. I looked for google and stackoverflow but there are unsolved problems or I couldn't see the solution.
Later I have tried to change python version but doesn't work again. Computers that have tried to running the exe, have same OS platform, I'm sure.
By the way, if you receive the following cx_Freeze error, resolving like this:
Build\exe.win-amd64-3.7\lib\scipy\spatial\cKDTree.cp37-win_amd64
change to
Build\exe.win-amd64-3.7\lib\scipy\spatial\ckdtree.cp37-win_amd64
Program uses the following modules : tkinter, pydicom, skimage, PIL, cv2, etc.
Primarily Program has 2 page that content code but I made single file for I came across this sentence "It's worth noting that pyinstaller can compile to a single .exe file"
What do you suggest I do? Thanks for your help.
Edit: I have been tried "Auto-py-to-exe" but I got an error (Fatal Error : Failed to execute script")
Edit2: I tried to run outside the anaconda. I think its work. But I'm still testing.
Edit3: I have tried to change python version, GUI was opened another computer but the program is not work properly. the program works on my computer but not on another computers
If you are not able to convert python file to executable format, you can try using auto py-to-exe library.
This library contains a GUI format to convert .py files to .exe
Here you can find auto py-to-exe with usage instructions,
https://pypi.org/project/auto-py-to-exe/

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.

Do I need multiple run configurations - one per Python file - in Pycharm even though the only difference between them is the script?

I created a Python project in Pycharm which contains multiple Python files. As of just now, I need to create a run configuration for each Python file in my project, even though they're all the exact same - with the exception of the script.
This seems unnecessary and laborious and I would love to just use one run configuration for multiple Python files.
That said, I'm a novice Python programmer just getting started and so still unfamiliar with large parts of the language.
My Project Files:
My Run Configuration - Used for all Python files:
Some Research Carried Out
I've searched for a solution and explanation to this, but have been unable to find anything. Some of the places I've tried:
JetBrainsTV on youtube (https://www.youtube.com/watch?v=JLfd9LOdu_U)
JetBrains Website (https://www.jetbrains.com/help/pycharm/run-debug-configuration-python.html)
Stack Overflow
I hope there is sufficient detail here, if not I'd be happy to elaborate.
If those files are independent and you have nothing specific to them, then I see two simple ways of running them:
You don't have to manually create a run configuration for every file. You can just Right-Click on the file in the project tree and click "Run "
You can use the Terminal and run them files using the python interpreter as needed.
I was facing a similar situation when I started competitive programming. In my case I wanted to redirect my Test Cases from an input.txt file rather than manually typing the test cases for every run of my code. Using the above solution was not feasible, as I would need to manually change the Script Path and Redirect Input path in the Run Configuration window for every script I was running.
So what I wanted was, one run configuration, that would run all the scripts with Redirect Input path being set to input.txt.
To do that,
I created a main.py file with the following content:
import sys
if __name__ == '__main__':
fname = sys.argv[1]
exec(open(fname).read())
This main.py file is going to run my other python scripts.
Created this run configuration for the main.py file.
Now, every time I needed to run any code, with the code window open, ran this configuration, which actually executed main.py with current file name passed as its argument, which would then also take the inputs redirected from input.txt.
Hope this helps you or anyone trying to run multiple python scripts with a single run configuration in PyCharm.

How do I bring up the page where I write Python program, compile and run it, and see the output?

Sorry if my questions are extremely stupid, but I'm quite at a loss while trying to use Python from Ubuntu Linux. My friend installed the Pycharm for me. I can go without using any commands, to files-->Pycharm projects---> click on one project and see the files, which I can open.
But I'm lost as of how to compile and run the files and see the output at this step? The .py files saved before (written with hello world and some really simple ones) are opening, but how can I see the output?
Also, when I go to the programs by files-->Pycharm projects---> file1.py, file 2.py...etc., do we code and run them from the terminal, using the Linux features? If not, how can I do all of the coding and running from the terminal?
Many thanks!!!
I'm not sure what you mean but "how can I do all of the coding and running from the terminal?" you can use nano to edit to code and run the code on the terminal too
see this link to know more about nano : HERE

Resources