I'm helping out a friend who needs to transform some data in csvs, so I made a little python program called "csv_converter.py"- it takes a csv input file and csv output file and everything's peachy.
I want to be able to give them a file they can run on their machine (without necessarily needing python and pandas) so I'm trying PyInstaller.
In the directory with my python program I run: pyinstaller csv_converter.py
According to the docs, it'll make a 'dist' folder where "you find the bundled app you distribute to your users." It sounds like the key file to run will be: dist/csv_converter/csv_converter (clarification source: here), and then I can either send the whole csv_converter folder, or just the csv_converter file if I run the Pyinstaller command with the --onefile argument.
After running PyInstaller I see these directories created, but when I navigate to dist/csv_converter/ and try to run that important csv_converter file (before trying to send anything), it's giving the following error:
Dianes-MacBook-Pro:csv_converter dkaplan$ ./csv_converter -h
Traceback (most recent call last):
File "site-packages/PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line 30, in <module>
FileNotFoundError: Tcl data directory "/Users/dkaplan/PycharmProjects/chris_csv_converter/src/dist/csv_converter/tcl" not found.
[36637] Failed to execute script pyi_rth__tkinter
So close, but so far! Has anyone else had this issue or know a workaround?
I heard back from the kind folks at PyInstaller, and this is a common one they see with tinter. I'm not sure where it was being pulled in from, but the workaround was to exclude it with this argument: --exclude-module=tkinter
I had chosen to use the --onefile argument (slower, but means I can send just one file), so the full command was: pyinstaller --onefile --exclude-module=tkinter csv_converter.py
Then:
I could go to the dist folder and do a test run with: ./csv_converter -h
then I send that csv_converter file to my friend and he'll be able to run it the same way (without needing python)
Related
I am creating an R script myscript.R which manipulates an excel file by means of XLConnectpackage.
The point is it refers to several external files: the excel file itself and another R file (functions library), so I need to set a working directory in the location of the script (so that relative paths to external files work properly).
I am using the following in my script
new_wd <- dirname(sys.frame(1)$ofile)
setwd(new_wd)
When I source the script from my RStudio it gets the job done. The problem is that the script is to be used by non-programmers, non-Rstutio-users, so I create .bat file (which I want to turn into an .exe one)
"C:\Program Files\R\R-4.0.3\bin\Rscript.exe" "C:\my\path\to\myscript.R"
It executes the script line by line but sys.frame(1) only works when sourcing.
How could I solve it?
Thanx
I have found a solution and it works properly.
From CMD command line or from a .bat file one can add an argument -e to the command, so that you can use a R language.
absolute\path\to\Rscript.exe -e "source('"relative\path\to\myscript.R"')"
It worked for me.
Besides, as Compo commented, I think there's no need for a .exe file, since a .bat does the job.
TLDR; Convert the bash line to download sftp files get Inbox/* to c++ or python. We do not have execute permissions on Inbox directory.
I am trying to read the files present in a directory in a remote server through SFTP. The catch is that I only had read and write permissions on the directory and not execute. This means any method that requires opening (cding) into the folder would fail. I need to read the file names since they are variable. From what I understand ls does not require execute privs. If I can get a list of files in the directory then reading then would be fine. Here is the directory structure:
Inbox
--file-a.txt
--file_b.txt
...
I have tried libssh but sftp_readdir required a handle of the open directory. I also looked at paramiko for python but that too requires to open the directory to read the file names.
I am able to do this in bash using send "get Inbox/* ${destination_dir}". Is there anyway I can use a similar pattern match but on c++ or python?
Also, I cannot execute bash commands through my binary. Does anyone know of any library in python or c++ (preferred) that would support this?
I have not posted here in a while so please excuse me if I am not following the formatting. I will learn from your suggestions. Thank you!
There is a CSV file called orders_data stored in my system, but when I try to load this file in Julia using readdlm command in Jupyter Notebook(running in my browser), it says "NO SUCH FILE DIRECTORY FOUND"
I'm not sure why does this happen? is there a specific location where the files need to be stored to be accessed using Julia command? is it that I need to install some packages first to load the file using browser version of jupyter?
//Error information
SystemError: opening file orders_data.csv: No such file or directory
Your working directory is set to your current location when you start a Julia session. You can see what it is by calling the pwd() function. You can change it by calling the cd() function. Unless you specify otherwise, or provide a more complete pathname, Julia looks for files in your current working directory (although it's different for modules).
I am trying to understand the working of "make" command (just started on this command). I have an ".sh" file which has a script to execute "make" command as shown below:
source /somepath/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
make arch=arm toolchainPrefix=arm-poky-linux-gnueabi- xeno=off mode=Debug all
The directory where the script file is located has a file named "makefile". but there is nothing specified in the script file above regarding this "makefile". After executing the script file, all the script withing "makefile" is executed automatically. Can someone explain the working of "make xyz all" command in few words.
Thanks
As often with UNIX systems the command works to some degree by conventions. make (the GNU version of make at least) will search the working directory for files called GNUmakefile, makefile, and Makefile in that order or you can use the -f (or --file) option to give it a specific file.
I am trying to run a programme on a debain dedi. Using the following code.
java -cp bin:lib/* rs.Server false 43594
However it gives me a file not found error (even though the files are present). I fixed this error in intellij by picking the $MODULE_DIR$ option. Is there a equivalent to this in unix terminals?
The problem looks to be that the directory your are in when you run the command is wrong. You either need to cd to the directory containing the bin and lib directories or specify the full path to the directories in the command line.