Pycharm using two projects to run - python

So I am trying to submit some coursework for university, but when I compress the project and send it to my friend, he cannot run it.
I noticed at the top of the console there is this line
"/Users/maxculley/Desktop/PART 2/bin/python" "/Users/maxculley/Desktop/UNI WORK/YEAR 3/Data structures and algorithms/Coursework 1/PART 2/CODE/main.py"
I located the files on my desktop and it seems as though I can only run this if the project has these files at that file path.
Anyone know why the project is using these files from two project?

FIXED -- Realised I didn't need to compress the whole folder, just the python files, the interpreter is what was causing the issue as this is what was located on my home screen

Related

How to bundle Python apps with asset dependencies for end users?

I have a Tkinter app that uses images included in the same folder as the .py file. pyinstaller script.py produces an executable that runs but does not open any windows. This is because it is looking for images that don't exist in the same subdirectory. When I copy the important images to the dist folder Pyinstaller creates, the application runs correctly.
However, I would like to have a single executable that I can share with other users that doesn't also require them to have the images stored. The images should be bundled with the software somehow, like how commercial software (usually) doesn't require you to download assets separately from the program itself.
Is there a way to bundle Python programs and the assets they use into single-click applications?
Note that I am using Python 3 on Linux Mint. I am also something of a novice, so don't be surprised if I'm missing something obvious here.
It appears I've solved my own problem.
Instead of having the images included in the same folder as main.py and using the resulting short relative filepath to reach them, install the images in an appropriate space in the system directory tree (I used /home/$USER$/.$PROGRAMNAME$/) and have the program access the files using the absolute path to that directory. This will allow you to copy the program anywhere on your computer you want and have it run without a problem.
However, if you want to share it with someone else, you'll need to also include an installation script that places the assets in the correct directory on their computer.

Convert a visual studio python project to one executable file

I have finished my python project and now want to transfer the project into one file, so a user can just double click it and doesn't have to compile it first.
Therefore, I wanted to know if this is possible with python.
I 've read that you can convert a single python script into an executable file using pyinstaller. But in my case I have many files in different folders and I want them to be include in the executable file because otherwise the programm doesnt work.
I also tried this via the auto-pyto-exe converter (https://github.com/brentvollebregt/auto-py-to-exe) but I didnt got the results I wanted.
Therefore, my question is, how can I convert my visual studio python-project with many different files and folders into one executable file, so a user can just double click the file to start it?
Edit
In the other folder are also .py files like some FileImport.py or View.py. I separated these files that the whole project looks cleaner.
The Folder structure looks as follows:
-Views
---MainView
---UpdateView
---AnotherView
-Controllers
---MainViewController
---UpdateViewController
-Model
---MainModel
I found the solution. As it appears the pyinstaller can find all dependencies when you compile your script via pyinstaller myscript.py. PyInstaller creates three different folders where all necessary files are located. In the dist folder one executable is located which can be used from computers without python installed.
I hope this helps somebody who has the same problem.

From .py to .exe with Kivy Python 3 and external library

I have made a program in Python which has two files. It has a python file (main file), and a kivy file which grabs a few images from the same directory. I also have used an external library located in a different folder with several dll and py files.
Now I want to convert this main python file into an exe, with everything working. I have tried to use auto py to exe multiple times (no kivy and external library, only external library, one file, one directory, etc), which is basically PyInstaller with a nice GUI. It worked to put it in one directory WITHOUT the kivy related stuff. But I want to have everything working (so main python file + kivy and pictures + external library) into a single exe file, rather than a whole directory.
I have also searched far and wide across the web, but can't find any solution.
I would greatly appreciate any kind of help!
Kind regards,
The Lion

Place Text Files in another location - selenium

Currently my program is using txt files (filled with data) that are located in the Desktop. I am going to be sending this out to users and the text files are going to be included in a installer. When installing I don't want these files to crowd the users desktop. Any ideas on this??
Kunwar, this is a somewhat subjective question, so this essentially is a subjective answer.
This is really about packaging. You've not provided any info on what your package lookslike, but in principle, why not just put the text files in the directory with your program?
your_program/inputs/*.txt
Then they will always be available to your tool. You can find the current location of your script within the script itself and build the path to the input file, no matter where the users have stored the script on their machines.

How to work within individual files rather than projects in PyCharm

Relatively new to Python and PyCharm and as such most of the work. I'm doing is single files and therefore is not organized into projects.
Is there a way to configure Pycharm to be used to open single files and not use projects?
Similarly, is it possible to just run a single page/file?
On Pycharm 5.0.4...
Open the file (i.e. by double clicking in explorer)
Navigate to File->Settings...
Expand the Project tab on the left and select 'project interpreter' from the options that appear beneath
Set your project interpreter from the dropdown menu, and you should be able now to run your file without creating a project
You can always open a single file (File > Open) but to actually run or debug the code from within Pycharm, or use most of its other features, it needs a correctly configured project.
What you can do is create a single project to hold all of your "assorted" code. I usually recommend creating a virtualenv for this project as well and using that as your Pycharm project interpreter. You can further divide this project into different packages to keep things organized.
Update: PyCharm 4.5 now provide Scratch Files which seem relevant to this question.
You have to work with a configured project (indicated by folders) but there is a work around... In Pycharm when you create a project you will have a default file in .py or any other format.
Just follow the steps to work with individual files..
right click on the folder (in left hand side project tree) and add new python file
double click on the newly added file ,it will now be open in a new tab
(BUT..if you try to run this new file pycharm will still compile the previous file ...so to change that..)
right click on the tab of your file and click run "file name" or you can press CTRL+shift+F10
done :)
From the command line
pycharm [path_to_your_file]
where pycharm on my machine is aliased to /opt/pycharm-community-3.1.1/bin/pycharm.sh in file ~/.bash_aliases.
As Preston mentioned, not all features seem to work: for example, navigation between files does not seem to work.
You can also create a .py file and implement it within a PyCharm project by dragging it into the editor. This method also allows you to use a separate text editor to create your .py file.

Categories

Resources