Hi I am running in windows XP. I have python2.6 and python 3.2 installed at the same time.
My problem is when i uninstall python 3.2 and run a program with an error, the CMD does not return error message. But the program execute properly when it has no error.
I've tried re installing python2.6 but it is still the same.
From the desktop, right-click My Computer and click Properties.
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
In the Environment Variables window highlight the Path variable in the Systems Variable section and click the Edit button.
Each directory is separated by a semi-colon. Add "C:\Python26" to the end (making sure it has a semi-colon before it).
Now you should be able to type "python test.py" from anywhere and it will work.
Here's how to fix the registry settings, so double-clicking a .py file will work:
Go into control panel, choose Add/Remove Programs. Find Python 2.6 and choose the option to repair it. Test to see if that fixed the problem.
If it still doesn't work, then: Go into control panel, choose Add/Remove Programs. Find Python 2.6 and choose the option to Change installed features. Choose to install the "Register as default Python" feature.
Related
I had Python version 2.7.17 already installed on my machine. Recently I started coding in Python and I installed VS Code to make things easier. However once I opened VSCode and ran a simple Python Hello World program, VSCode terminal gave a warning saying that
Python 2 support has ended at January 1, 2020
which means the support has already ended and suggested to install the latest Python version. So I heeded the warning and installed Python 3.8.5 on my Windows machine. The installation was completed without any issue. Afterward, when I tried the command python --version on VSCode terminal, it correctly gave the output python 2.7.17. However, when I tried the command python3 --version to check if it was correctly installed, the terminal gave no output.
Since I am a beginner and the support for Python 2 has already ended, I would like to work with Python3 from now on. However, I don't mind Python 2 staying in the machine.
Is this something should I worry about? Or should I uninstall Python 2 completely (When I checked Control Panel both versions are list under currently installed programs)?
According to your description, you can change pythonpath in vscode and still keep python2.
I assume you are using windows system and if not, please let me know. The following is the solution:
open cmd and type: where python. There should be two path, copy it which is about python3.8.5;
press Ctrl+, to open setting.json and add an entry for python.pythonPath manually inside your User Settings:
Now you can press Ctrl+Shift+P and find the option select interpreter. Click it you'll find a interpreter list. After selecting new interpreter, it is necessary to press Ctrl+Shift+` to open a new terminal for further development.
About more detailed information about pythonpath and interpreter you can refer to using python environments in vscode.
The version of Python used depends on your environment, and PATH variable.
I think you need to select the correct Python interpreter. At the bottom of your screen, there should be something that says the Python version number. If you click it, you can get a menu to select the interpreter.
Alternatively, you can hit control-shift-p, type "python interpreter", then click "select python interpreter" option.
Finally, you can alter the default Python interpreter used by changing the User settings in VS Code. Hit control-shift-p, type "open settings", and select Open Settings (JSON). Add a key to the JSON file called "python.pythonPath", so that you have a line that looks something like this:
"python.pythonPath": "full/path/to/the/python/executable/you/want/python.exe",
You might be able to get a hint as to the path to use or available isntallations of python if you type where python or which python (depending on terminal/ OS in use).
Then you can save those settings. Restart VS Code. Hopefully now the correct interpreter is selected by default.
The Command Prompt does not do anything when I use the Python command to execute a module. It does not even do anything when I use it at all; it just pretends that I did not do anything, and goes back to the current working directory. Attached is a screen shot for clarity.
Apparently, if you call python from Windows' Command Prompt (at least with my home computer), it will look for any python version installed using Windows Store, so if you just type python, it will open the Windows Store for you to install.
If you have Python installed, try to call full path to executable or try to add the path containing your Python executable (in my case, C:\Python38) to the system environment variable PATH:
Search for "Edit the system environment variables".
Click the Environment variables... button (in the Advanced tab)
Edit PATH and append ;C:\Python27 to the end (substitute your Python version)
Click OK and reopen cmd for change to take effect.
Update.
I simply uninstalled and reinstalled Python. Once I did that, the program works as it should in CMD.
If you have python already installed, you should just be able to type 'python' alone then press enter. It should then give you a space to execute python code. It could be simple fix, but if not it's still worth a shot.
When its the first time you're going to install python on Windows it shows you the option Add to path unchecked, so you just need to check that option and install python, you can uninstall python and installet again with the check, this fix the problem.
I just use the IDLE, it is the easiest way to run python scripts. Just open up IDLE and click on File < Open.. < and select your file. Then make any last minute changes and click on File < Save. Click on Run < Run Module (or F5) to run the python script. Done.
This is great for people that want to use python 2.7 or just don't want to install the python application from the Microsoft store.
Sometimes the order in which the PATH environment variable is set also matters; if the Windows store variable is before the path where Python is installed then the windows store will open when you type python.
My IDLE option in the right click menu has disappeared.
I think it's because I use Python 3.5.2, but I installed Python 2.7.12 without uninstalling Python 3.5.2. Later I uninstalled Python 2.7.12 and from then on the .py files are opening in either Chrome but I cannot get it to open with IDLE. And the usual logo for Python scripts has disappeared. Instead now it has the logo in the picture. What can I do? I uninstalled Python 3.5 after the problem and reinstalled it. Yet the problem persists.
An alternative approach would be to modify your Python installation. I would advice against reinstalling Python because you stand to lose your installed modules and scripts. But if you don't mind starting over again, reinstalling Python will fix this.
To modify your Python installation:
Open the Control Panel.
Uninstall Python Launcher.
Click on Python 3.6 (or the version you
have.)
Choose Modify.
On the Optional Features page, make sure the
.py launcher checkbox is checked.
Proceed and wait for the setup to finish.
After it's done, you can either restart your computer or
sign out then sign in.
Now when you right click on your .py files, Edit With IDLE will show up in the context menu. Keep in mind that your .py files should Open With Python Launcher.
Hope this helps.
Option 1:
Right click on any .py file and click Open With and click choose default Program or Choose another app.
From the list that appears after if you see python.exe choose that otherwise click Choose another program or Browse option. Might that option appears after clicking More App in Windows 10.
Next browse to python insallation directory and select python.exe
Option 2:
Run regedit and goto key HKEY_CLASSES_ROOT\.py and change the default to Python.File.
After that logout & login. Context menu will appear again.
At time of saving python code...will display two extensions .py and .pyw.
Save file using .pyw extension, i.e. instead of dropcols.py save it as dropcols.pywwill solve your problem. This worked for me.
This is the same question as this else but for Python.
The thing is that I've built my own installer package of Python interpreter (I've added modules and extras) and once installed I can't find the way to set the location of my custom Python installation dir in PyCharm IDE, I can't find any option to manually specify the location of python interpreter.
While I don't know if exist that option I'm thinking in other alternative, If maybe the PyCharm IDE takes the original Python path from a registry value then it should be sufficient for set the location, but I don't know if pycharm uses a config file or a reg key to get the python location and where is this value to modify it, I need help.
PS: I'm having the same problem for RubyMine IDE.
For PyCharm, in the IDE go to File -> Settings. In the Project Settings navigation panel, select Project Interpreter and then Python Interpreters, then in the right panel, click on the green plus (+) icon on the top right and select local. Navigate to the python executable you would like to specify as your interpreter.
You can also try this:
click on File
select Settings from the menu
in new Settings window click on Project and then Python interpreter
click on gear icon on the right, then on Add... option
in the Add python interpreter window select System interpreter from the list on the left
pick Python, click apply and you are done
I was having similar problems with PyCharm.
Having installed both Python 2.7 and 3.5 I was only able to find the the "python.exe" file for python 2.7.
I tried reinstalling Python 3.5 and attempting to change the installation path to C:// but it lead to several errors. This is the work around I found for getting 3.5 on PyCharm as an interpreter.
Copy the python 3.5 directory in windows explorer.
Paste it into PyCharms choose local interpreter area.
On my mac I am trying to make a Python script open by default in the Python Launcher.
I left click on the script and select "open with" and select the Launcher. Every-time I do this Terminal pops up, the Launcher window appears briefly. Then a messages pops up in a window: "Python Launcher can only run certain scripts try another."
Something along those line (the message has stop popping up since the first time I tried it but the script still doesn't run). I tried everything, GUIs, and basic scripts (like print "Hello World"). None work!
I tried doing the same thing on other computer and I get the same problem. What am I doing wrong ?
Does your script use a shebang line:
#!/path/to/executable/python2.6
And does it have execute permissions?
chmod +x path_to_file.py
It should run OK like this.
Assuming you're talking about Anaconda, Launcher is now deprecated, so your approach will have to change anyway. It has been replaced by Navigator.
Make sure you have updated Anaconda within terminal using
conda update conda
Then, you can install Navigator with
conda install anaconda-navigator
You will see a new icon show up that functions much the way Launcher used to. Your script will now have to be tied to it instead of launcher, assuming you figured that out with previous commenters' help.