Installing Pypotrace for python - python

On a thread supposedly detailing how to install Pypotrace on Windows (Installing Pypotrace for python?), someone was told:
"You need to install mingw and make sure it is working in msys mode - run msysand you should get a command prompt in it type gcc --version and make sure you get a sensible reply. also make sure your Python runs from within msys."
In response to the comment that
"You should get a command prompt in it type gcc --version and make sure you get a sensible reply"
I noted that I don't- I get "command not found." What should I do to
resolve this issue?
"Also make sure your Python runs from within msys."
How can I check this?
In response to the question
"Do you have ez_install.py?"
I do. But "Is it on your path?" only leaves me wondering: Which path?
Is it possible to explain any of this clearly, without skipping important issues like what programs are being used, or what to do when something isn't working, and what paths are meant?

Please modify your system path with gcc and easy_install paths as below:
import os
os.environ["PATH"] += os.pathsep + path_to_your_executable_file
where path_to_your_executable_files should be a string like "C:\\Program Files\\Python27".
Also (for Windows OS) you can do the same step-by-step with this instructions: http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path

Related

Python.exe works with -v or -h but will not execute a file. What is wrong?

The python programs on Windows have stopped executing scripts.
It will run python. For example, I can check the version and get the help text.
I've tried running it from "c:/User/.../python.exe", `py -3, etc.
I've also installed all Windows updates and re-installed python. (from version 3.8 to 3.10.7; same issue for both.)
Also, I've tried it from both power-shell and cmd.
I have tried a variety of scripts, but I have a test.py which just prints something.
Also, I've tried py -3 -c 'print("Hi")'. It does not work either.
All of these do not print any diagnostics. I simply get the shell prompt on the next line. I can also tell that the script is not even loaded. For example, if I give a filename that does not exist it does the same thing; no error message. The same occurs if I add a syntax error to the file.
I am seriously stumped. What could cause this?

First time trying to run python from Powershell. Am I using the right command/ what do I need to do to permit use of Python?

I'm trying to run some Python files from command line, using PowerShell, but I'm really unfamiliar with the shell, and I've run into some issues trying to run python. I think there is some preparation process for python that I've missed, but I don't know what.
In trying to run Python through Powershell, I've tried installing Python 2.7 on my computer. While it changed the nature of the error message I was first receiving, it has otherwise not done much.
I've also tried doing some research to see what might be going wrong, personally, but I'm having some trouble finding an exact answer to my problem, and therefore figured I'd try asking, on here.
From what I've seen, online, I think this is the correct way to call and run a python file in Powershell. It's what I'm currently using:
PS C:\Users\nickd\documents\Coding\Comp_Sci_Class\Python\debugger> python my_test.py
This should run a program that tests whether or not a debugger is working. Instead, I get the following error message when I try and use the command 'python':
python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python my_test.py
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
As such, I'm led to believe that there is some step in preparing Python for use on Windows Powershell that I'm just missing, but I'm not finding a clean cut answer for what that might be.
Could somebody please help me out, and describe what it is I might need to do? I know that what I'm missing is likely extremely simple, and I apologize upfront if this is a silly problem to have. That said, if somebody could point me in the right direction as to what I need to do, I'd be really grateful.
Thank you.
Powershell doesn't find where you have installed python. If you add the folder where python.exe is located to path then it will work.
See here https://superuser.com/a/143121
You have to add location of Python.exe to your environment variable..
Your path might be C:\Program Files\Python27
Please follow the below steps :
1) Right Click on This PC (My Computer) and Select Properties ( Win Key + Pause key)
2) Click on Advance system setting from left pane
3) Click on Environment Variables...
4) select variable called "Path" from second list box
5) Click on Edit button below the same list box
6) Add python.exe full path ( do not include filename )
7) close all dialogs by clicking OK
8) restart your powershell | ISE
Since Python 3.3, the PythonLauncher is installed with Python on Windows. It is py.exe and is already in the PATH (c:\windows) if you did an "all users" installation. The default installation of Python also registers py.exe as the default handler for .py files.
Normally, with py.exe registered as the default handler, mytest.py would be sufficient to run the script, but since Powershell doesn't search the current directory by default, you can use .\my_test.py if it is in the current directory.
Otherwise, just run py my_test.py (if "all users" installation) or add the user directory where py.exe was installed to PATH if not. If you have multiple versions of Python installed, py -3.6 (for example) will run Python 3.6.
More information:
Python Launcher for Windows
Using Python on Windows

Installed older version of Python, can't get PATH to direct

I'm receiving the message:
The program can't start because python34.dll is missing from your computer. Try reinstalling the program to fix this problem.
I want to use python27, so I uninstalled python34, but can't get the cmd prompt to redirect to the python27 .dlls.
In the prompt I typed setx PATH "c:\python27" and it says successful. I close out of the prompt, open it again, type Python, and I get the same message.
Here is a screenshots of the error:
And a screenshot of the response to the setx command:
How can I fix this?
I would suggest you manually edit your PATH (through Windows' GUI instead of CMD) and ensure two things:
a) That C:\python27 is in there and
b) That C:\python34 is not in there
Also, after doing that, make sure you close all open cmd.exe dialogs before opening a new one and testing again.
CMD is a bit weird in my experience, it seems like as long as one instance of it is running, Windows won't propagate environment variable changes to any instances of it (even new ones created after the change). I wasted a lot of time in the past troubleshooting issues similar to yours until I figured that out, so I think it's worth mentioning here.

How to setup Atom's script to run Python 3.x scripts? May the combination with Windows 7 Pro x64 be the issue?

I'm trying to switch from Notepad++ to Atom, but I just can't manage to get my scripts executed in Atom.
I followed this answer (so I already installed script) which is not really extensive and also the rest on the web doesn't offer anything comprehensible for beginners.
In Notepad++ NPPexec I used to
NPP_SAVE
cd "$(FULL_CURRENT_PATH)"
C:\Python34\python.exe -u "$(FULL_CURRENT_PATH)"
and in Sublime Text 2 I made it run by creating a new "Build System":
{
"cmd": ["C:\\python34\\python.exe", "-u", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Can you please guide me how to setup Atom to be able to execute Python scripts with Python 3.4 scripts with a keyboard short-cut?
I already tried to set my init-script to:
process.env.path = ["C:\Python34\python.exe",process.env.PATH].join(";")
respectively
process.env.path = ["C:\Python34",process.env.PATH].join(";")
with no success.
When I go to Packages -> Script -> Configure Script and type
C:\\Python34\\python.exe
it works. But thats not a permanent solution.
When I press Ctrl+Shift+B to run a script, without configuring it before (as it is supposed to work), I get (suggestion of ig0774's comment implemented):
(it doesn't matter whether it is C:\Python34 or C:\Python34\)
It complains that python is not in my path - but it is.
I read multiple times that Windows 7/8 64bit together with Python 3.x could cause issues with certain packages. May this be the reason in ths case as well? I have Windows 7 Pro x64.
Update
As I've switched to VSCode and probably stay there, I'm not willing/don't have the time to try out all the answers, so I let the community judge the answers and accept always the highest voted. Please ping me, if it's not correct anymore.
This can be easily solved by editing the /home/.atom/packages/script/lib/grammars.coffee file (note that the atom folder is hidden so you might have to press ctrl+H to view hidden files and folders)
Inside grammars.coffee find:
Python:
"Selection Based":
command: "python"
args: (context) -> ['-u', '-c', context.getCode()]
"File Based":
command: "python"
args: (context) -> ['-u', context.filepath]
and replace with:
Python:
"Selection Based":
command: "python3"
args: (context) -> ['-u', '-c', context.getCode()]
"File Based":
command: "python3"
args: (context) -> ['-u', context.filepath]
Save changes, restart Atom and enjoy running your scripts with python 3
EDIT: On Windows I believe the grammars.coffee file is located in
C:/Users/Your_Username/AppData/Local/atom/packages
Again, the AppData folder is hidden so you might have to change your settings to view hidden files and folders.
To expand on #matt-nona answer. You can go to his mentioned config file right from Atom. Simply go to settings then "Open Config Folder":
Then /packages/script/lib/grammars.coffee Find "Python" and make the appropriate change to python3:
Following up on Matt Nona's advice , when Atom starts-> Welcome Guide (or control+shift+T)-> 5th one down 'Hack on the Init Script'. A blank page will open and you can add that modifications in there.
Update: for any other souls looking for this answer - On my Mac I do not have a grammars.coffee file within atom script config file.
Instead, there s a grammars folder, and I have a python.coffee file in there. The same changes outlines in the screenshot (ie add '3' to the end of the two mentions of python) fixed my issue and atom automatically runs Python3 now.
Not sure if the above answers are Windows specific or if there have been dev changes since 2017.
same problem just like you. 'Packages -> Script -> Configure Script' is not permanent. So I has tryed another script runner:https://atom.io/packages/atom-runner, just found the problem is in the python script itself.
When I use atom-runner, I got error message like this:
atom-runner error
So it remind me that in the beginning of the python script: ' #!/usr/bin/env python3 '
It's obvious that the ENV_PATH is WRONG here. I should revise it in my python script.
Setting the PATH within Atom did not work, setting it with the cmd, via
set PATH=%PATH%;C:\Python34
neither, and setting it in the Windows 7 system properties failed as well.
However reinstalling Python 3.4 and check Add python.exe to Path
seems to be neccesary. Also I needed to uninstall Atom completely (inculding all packages or a least script) and reinstall it from scratch.
After all these steps:
Install Python with Add to Path
Install Atom
Install script package
it works out of the box (Ctrl+Shift+B) and no further steps are required.
I still don't know what was the reason before and I don't know which of this steps are really required. So feel free to include your procedure without reinstalling everything.
Update
Reinstalling everything is certainly not necessary, simply updating/repairing the installation with the installer is sufficient.
Use the script-runner https://atom.io/packages/script-runner/
"N.B. these keyboard shortcuts are currently being reviewed, input is welcome.
Command Mac OS X Linux/Windows
Run: Script ctrl-x alt-x
Run: Terminate ctrl-c alt-c"
And "Run Terminate" (Alt + c) to use the current python in your system.
edit your python.coffee script
$ sudo nano .atom/packages/script/lib/grammars/python.coffee
For Linux and Mac, adding environment in the script will pick correct python version. (command + I to run)
for running with python3
#!/usr/bin/env python3

unable to install PunJab

I am unable to install PunJab on my system.
PunJab is a HTTP jabber client
interface. It is a BOSH connection
manager that allows persistent client
connections to a XMPP server.
When I type the following command
python setup.py install
It says invalid syntax error.. I have python 2.7 and twisted python 10.2 running on windows XP.I have set the environment variables for python...
What have I done wrong ?
Thanks
wat the heck is punjab?? I have no clue what it is.. But anyways when you add it to your system path it doesnt become part of your system path immediately.. A restart is normally required.
Instead what I would suggest is go to your python install directory and find the executable or python script that is needed to run this program and go to the command prompt and run it with your file name.
Going to Cmd prompt: Start -> Run -> type cmd and Enter
A black box should appear and now type the executable full path that you need to use like
C:\Python27\python.exe "location of your file"
thus your command should look like
C:\Python27\python.exe C:\users\kavya\Desktop\Punjab.py
Well hope that helps and please let me know wat the heck is Punjab and I know u r nt talking abt the state..

Categories