Why does komodo edit require a duplicate .py file to execute my commands? - komodo

I am using Komodo edit 7.1 on a macbook pro running OS X mountain lion
Note that the duplicated file needs a space at the beginning. e.g:
to execute hello-world.py, I wrote the code given in the lesson but when running the command i get an error
/bin/sh: /usr/bin/pythonhello-world.py: No such file or directory.
When I create a file name: _hello-world.py (the underscore is actually white space) and execute it from there, the command completes the action correctly
'/usr/bin/python hello-world.py' returned 0.
Interestingly enough, the code for the duplicated file can be blank, somehow it is choosing the proper file.
p.s. obviously I am brand new at this. I have searched google for similar problems but haven't found what I need. Please help!
Thank you

The path to the python executable is not setup correctly. Use the Terminal to fix it.

Related

Mac executable not working when downloaded online

I have made a small (8 MB) program into a MAC executable (.app?)
It works great if I share it using a thumbstick, but if I try to upload it to google drive and then download it it doesn't work. By this I mean It first tells me that It is an unidentified source (this seems reasonable)
But then if I click "open"
It opens as a text file with junk data:
If I try to force it to open on the terminal, how the other program opens, it just shows the heartbeat thing that MACs do when opening a file, but never opens anything.
It is certifiably the same exact file. Same size, same name, same goobldygoop if I open both of them as text files instead of executables.
I am really confused, the only thing I can think of is the "signature" that apple uses is lost when it is compressed into a zip, but I'm probably totally off base.
The code uses python 3.7, pyinstaller, pynput, and selenium.
I am using MAC OS Catalina to write and make into an EXE, then another Catalina to try to run the program.
EDIT: Clarify what doesn't work means
Please help.
I found the answer, simply zip the file from my mac and send it that way!
Yay!

PyCharm project path different from interactive session path

When running an interactive session, PyCharm thinks of os.getcwd() as my project's directory. However, when I run my script from the command line, PyCharm thinks of os.getcwd() as the directory of the script.
Is there a good workaround for this? Here is what I tried and did not like:
going to Run/Edit Configurations and changing the working directory manually. I did not like this solution, because I will have to do it for every script that I run.
having one line in my code that "fixes" the path for the purposes of interactive sessions and commenting it out before running from command line. This works, but feels wrong.
Is there a way to do this or is it just the way it is supposed to be? Maybe I shouldn't be trying to run random scripts within my project?
Any insight would be greatly appreciated.
Clarification:
By "interactive session" I mean being able to run each line individually in a Python/IPython Console
By "running from command line" I mean creating a script my_script.py and running python path_to_myscript/my_script.py (I actually press the Run button at PyCharm, but I think it's the same).
Other facts that might prove worth mentioning:
I have created a PyCharm project. This contains (among other things) the package Graphs, which contains the module Graph and some .txt files. When I do something within my Graph module (e.g. read a graph from a file), I like to test that things worked as expected. I do this by running a selection of lines (interactively). To read a .txt file, I have to go (using os.path.join()) from the current working directory (the project directory, ...\\project_name) to the module's directory ...\\project_name\\Graphs, where the file is located. However, when I run the whole script via the command line, the command reading the .txt file raises an Error, complaining that no file was found. By looking on the name of the file that was not found, I see that the full file name is something like this:
...\\project_name\\Graphs\\Graphs\\graph1.txt
It seems that this time the current working directory is ...\\project_name\\Graphs\\, and my os.path.join() command actually spoils it.
I user various methods in my python scripts.
set the working directory as first step of your code using os.chdir(some_existing_path)
This would mean all your other paths should be referenced to this, as you hard set the path. You just need to make sure it works from any location and your specifically in your IDE. Obviously, another os.chdir() would change the working directory and os.getcwd() would return the new working directory
set the working directory to __file__ by using os.chdir(os.path.dirname(__file__))
This is actually what I use most, as it is quite reliable, and then I reference all further paths or file operations to this. Or you can simply refer to as os.path.dirname(__file__) in your code without actually changing the working directory
get the working directory using os.getcwd()
And reference all path and file operations to this, knowing it will change based on how the script is launched. Note: do NOT assume that this returns the location of your script, it returns the working directory of the shell !!
[EDIT based on new information]
By "interactive session" I mean being able to run each line
individually in a Python/IPython Console
By running interactively line-by-line in a Python console, the __file__ is not defined, afterall: you are not executing a file. Hence you cannot use os.path.dirname(__file__) you will have to use something like os.chdir(some_known_existing_dir) to reference a path. As a programmer you need to be very aware of working directory and changes to this, your code should reflect that.
By "running from command line" I mean creating a script my_script.py
and running python path_to_myscript/my_script.py (I actually press the
Run button at PyCharm, but I think it's the same).
This, both executing a .py from command line as well as running in your IDE, will populate the __file__, hence you can use os.path.dirname(__file__)
HTH
I am purposely adding another answer to this post, in regards the following:
Other facts that might prove worth mentioning:
I have created a PyCharm project. This contains (among other things)
the package Graphs, which contains the module Graph and some .txt
files. When I do something within my Graph module (e.g. read a graph
from a file), I like to test that things worked as expected. I do this
by running a selection of lines (interactively). To read a .txt file,
I have to go (using os.path.join()) from the current working directory
(the project directory, ...\project_name) to the module's directory
...\project_name\Graphs, where the file is located. However, when I
run the whole script via the command line, the command reading the
.txt file raises an Error, complaining that no file was found. By
looking on the name of the file that was not found, I see that the
full file name is something like this:
...\project_name\Graphs\Graphs\graph1.txt It seems that this time
the current working directory is ...\project_name\Graphs\, and my
os.path.join() command actually spoils it.
I strongly believe that if a python script takes input from any file, that the author of the script needs to cater for this in the script.
What I mean is you as the author need to make sure you know the following regardless of how your script is executed:
What is the working directory
What is the script directory
These two you have no control over when you hand off your script to others, or run it on other peoples machines. The working directory is dependent on how the script is launched. It seems that you run on Windows, so here is an example:
C:\> c:\python\python your_script.py
The working directory is now C:\ if your_script.py is in C:\
C:\some_dir\another_dir\> c:\python\python.exe c:\your_script_dir\your_script.py
The working directory is now C:\some_dir\another_dir
And the above example may even give different results if the SYSTEM PATH variable is set to the path of the location of your_script.py
You need to ensure that your script works even if the user(s) of your script are placing this in various locations on their machines. Some people (and I don't know why) tend to put everything on the Desktop. You need to ensure your script can cope with this, including any spaces in the path name.
Furthermore, if your script is taking input from a file, the you as the author need to ensure that you can cope with changes in working directory, and changes of script directory. There are a few things you may consider:
Have your script input from a known (static) directory, something like C:\python_input\
Have your script input from a known (configurable) directory, use ConfigParser, you can search here on stackoverflow on many posts
Have your script input from a known directory related to the location of the script (using os.path.dirname(__file__))
any other method you may employ to ensure your script can get to the input
Ultimately this is all in your control, and you need to code to ensure it is working.
HTH,
Edwin.

primer3_core Error: First line must be "Primer3 File - http://primer3.sourceforge.net"

I am currently using Primer3 2.3.6 in Linux. I am using the command "primer3_core -p3_settings_file=/my/path/to/settingsfile.txt /my/path/to/inputfile.txt".
I also tried it in Windows 7 and it worked without any problem. However, in Linux I got the error message "primer3_core: First line must be "Primer3 File - http://primer3.sourceforge.net"..". But the missing line is in the first line of my settings file.
Do you have any suggestions or ideas what could be wrong?
Thanks in advance!
Okay, I could solve the problem. It was more a mistake of myself, because I edited the default settings file, provided by primer3, using word pad in windows. Thereby, I changed the formatting and primer3 was not able to use it anymore.
Now I just use the text editor or visual studio to change parameters in the settings file.

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

perl5 Number Sign # not working for comments

I have a very strange problem..
perl5 Number Sign # not working correctly for comments..
We use emperl, mod_perl, apache, linux..
In some programs if I have a line commented out with a number sign # or just a number sign # by itself on a line, all of the code below that line doesn't work correctly.
There is a sysadmin so I don't have access or control over any of the settings on the server.
This is a new issue everything always worked previously.
So many possible area's that this might be coming from that I'm checking to see if anybody has run across this..
Any suggestions?
Found the issue:
Was transferring the files from LINUX to Windows to edit them.
If the file was originally created in Windows the end of a line was just a <CR> and for some reason the whole file wasn't running right. It mainly showed up when using the hash symbol for perl comments.
When I made sure the files had end of lines with <CR><LF>, this solved this issue.

Resources