Installing Python 2.7 on Windows 8 - python-2.7

So I'm trying python 2.7 on my Windows. It is running Windows 8. I cannot add it to my path. I've done the usual: using the advanced system settings, environment variables, adding C:\Python27 in system variables.
However, when I type Python in command prompt it says 'python is not recognized ..'

I think that the essence of this question is how to install Python and be able to use it from the command line. The steps below show how to get all that working. Check that you didn't miss anything:
From https://www.python.org/download/releases/2.7.6 download appropriate Python 2.7.6 Windows Installer. (If that link doesn't work, check https://www.python.org/downloads/)
Run the file
Select install for all users or install just for me, click Next
You'll see it installs under the C:\Python27 folder, click Next
Click Next again for the 'Customize Python' step
Click Finish
Open Control Panel, then System
Click 'Advanced system settings' on the left
Click the 'Environment Variables' button
Under 'System variables' click the variable called 'Path' then the 'Edit...' button. (This will set it for all users, you could instead choose to edit the User variables to just set python as a command prompt command for the current user)
Without deleting any other text, add C:\Python27; (include the semi-colon) to the beginning of the 'Variable value' and click OK.
Click OK on the 'Environment Variables' window.
Open a new command prompt window type python, you will have python running in the command prompt. Note: command prompt windows open prior to setting the Environment Variable will not have the python command available.

Easiest way is to open CMD or powershell as administrator and type
set PATH=%PATH%;C:\Python27

System variables usually require a restart to become effective. Does it still not work after a restart?

Make sure you don't put a space between the semi-colon and the new folder location that you are adding to the path.
For example it should look like...
{last path entry};C:\Python27;C:\Python27\Scripts;
...not...
{last path entry}; C:\Python27; C:\Python27\Scripts;

How to install Python / Pip on Windows Steps
Visit the official Python download page and grab the Windows installer for the latest version of Python 3.
python.org/downloads/
Run the installer. Be sure to check the option to add Python to your PATH while installing.
Open PowerShell as admin by right clicking on the PowerShell icon and selecting ‘Run as Admin’
To solve permission issues, run the following command:
Set-ExecutionPolicy Unrestricted
Next, set the system’s PATH variable to include directories that include Python components and packages we’ll add later. To do this:
C:\Python35-32;C:\Python35-32\Lib\site-packages\;C:\Python35-32\Scripts\
download the bootstrap scripts for easy_install and pip from https://bootstrap.pypa.io/
ez_setup.py
get-pip.py
Save both the files in Python Installed folder
Go to Python folder and run following:
Python ez_setup.py
Python get-pip.py
To create a Virtual Environment, use the following commands:
cd c:\python
pip install virtualenv
virtualenv test
.\test\Scripts\activate.ps1
pip install IPython
ipython3
Now You can install any Python package with pip
That’s it !!
happy coding
Visit This link for Easy steps of Installation python and pip in windows http://rajendralora.com/?p=183

Type this in Windows PowerShell or CMD:
"[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")"
After running the command, please restart PowerShell or CMD. If it still doesn't work, restart your PC.

there is a simple procedure to do it go to controlpanel->system and security ->system->advanced system settings->advanced->environment variables
then add new path enter this in your variable path and values

i'm using python 2.7 in win 8 too but no problem with that. maybe you need to reastart your computer like wclear said, or you can run python command line program that included in python installation folder, i think below IDLE program. hope it help.

GUI Option:
Open System Properties
a. Type it in the Start Menu
b. Use the keyboard shortcut Win+Pause)
c. From Windows Explorer address bar go to
%windir%\System32\SystemPropertiesProtection.exe
d. Write SystemPropertiesProtection in run window and press Enter
Switch to the Advanced tab
Click Environment Variables
Select PATH in the System variables section
Click Edit
Add python's path to the end of the list (the paths are separated by semicolons).
For example:
C:\Windows;C:\Windows\System32;C:\Python27
Command Line Option:
Run Command Prompt as administrator
Check existing paths under PATH variable (the paths are separated by semicolons). If your python folder already listed then no need to add again. Default python folder is C:\Python27
C:\Windows\system32>path or C:\Windows\system32>echo %PATH%
Append python path using setx command. The /M option sets the variable at SYSTEM scope.
The default behavior is to set it for the USER.
C:\Windows\system32>setx /M PATH "%PATH%;C:\Python27"

Related

macOS Catalina: trying to install content to the system volume

I have apps that I distribute as .pkg files created using pkgbuild and productbuild. With macOS Catalina, this doesn't work any more. The installer complains that I'm trying to install content to the system volume.
I posted three weeks ago thinking the error had to do with bundling a Java runtime. It turns out it has nothing to do with Java.
To test it I have the smallest possible project called Hello with a main window and a button to click. In XCode, I do Product -> Archive, then Distribute App, and Copy App. This creates a directory Hello 2019-12-18 15-01-07 with contents Hello.app. The app works fine. I then
pkgbuild --root *7 Hello.pkg
which creates Hello.pkg.
When I double-click Hello.pkg in the finder the installer presents me with screens for Introduction, Destination Select (only one option is offered), and Installation type ("Standard Install on Macintosh HD"), then asks me for my password. It then says, "This package is incompatible with this version of macOS. The package is trying to install content to the system volume. Contact the software manufacturer for assistance."
It makes no difference if I codesign and notarize. Productbuild only adds one more layer to the failing process.
What am I missing?
We could fix the issue by using the option
--install-location
of the pkgbuild command.
If the
--install-location
option is not used, pkgbuild uses / as the default install location in many cases.
In macOS Catalina, only certain folders are writable. Refer this link for more details.
In our case, the package installation succeeded only when we specified one of the writable folders such as
/usr/local
/opt
/Applications
as the default install location.

Problem importing torch in command prompt, but it works directly in VS code / Jupyter

I am trying to run a flask app in my command prompt on Windows 10. Whenever I try to run it, it errors out when trying to import torch. I have created a fresh environment and installed the latest pytorch from this page https://pytorch.org/get-started/locally/ but it still doesn't work in command prompt. Oddly, if I just execute code that says "import torch" in jupyter notebook or VS code, it doesn't error out. It only gives me the error in Command Prompt.
Does anyone know what the issue could be?
Short answer: If possible, use Anaconda Prompt. It's accessible from the Start Menu > Anaconda > Anaconda Prompt.
Long answer: The problem is due to the order of the different Python installations in the PATH variable, as you can see with echo %PATH%. System Python comes first, which can be seen with which python.
The recommendation is to use Anaconda Prompt, since it properly sets up the PATH variable with all required Anaconda paths. More importantly, it avoids interfering with other software in regular command prompt. So, your command prompt won't have any unintended consequences from using Anaconda.
If there is a reason that requires you to use regular command prompt, you can change the order with set PATH=C:\Anaconda\;%PATH% (temporary for this command prompt) or setx PATH=C:\Anaconda\;%PATH% (permanent). There are other libs that may be required to be included as well, which you can check by printing the PATH variable at the Anaconda Prompt.
Another option (Win10): Start Menu > type 'environment' > click 'Edit the system environment variables'. Click Advanced > Environment Variables... Double click Path and change the order between system Python and Anaconda Python.

multiple install of python, package install by pip are in wrong directory windows

I know this similar question has been answered before but I made the mistake of installing python 2.7 after a Anaconda installation. Now when I use the pip function in cmd, it install the package in the python 2.7 folder and not the Anaconda folder. using python -m pip function in cmd I get:
c:/python27/python .exe -m pip
I just want to use the Anaconda directory instead of this.. any easy way to specify it?
thank you..
You have to change your PATH environment variable so that the Python 2.7 directories are removed. The easiest way is to uninstall this extra Python version. If you would like to edit the PATH directly, see here: https://superuser.com/a/284351/229278
To quote the answer for Windows:
Windows
GUI
Open Control Panel » System » Advanced » Environment Variables.
Type control sysdm.cpl,,3 in the Run dialog (+R) and click Environment Variables.
For editing user variables you can also type
%windir%\System32\rundll32.exe sysdm.cpl,EditEnvironmentVariables
in the Run dialog.
Right-click (My) Computer and click on Properties, or simply press +Break.
In XP click on Advanced » Environment Variables.
In Vista+ click on Advanced system settings » Environment Variables.
There are many other ways of reaching the same place, such as by typing "environment variables" in the Start Menu/Screen search box and so on.
Environment variables in Windows are separated into user and machine/system specific values. You can view and edit their values there. Their current values upon launch are made available to all programs.
There is also Rapid Environment Editor, which helps setting and changing environment variables in Windows without the need to go deep into the system settings. Another open source program for Windows with which the path environment can be edited very conveniently is Path Editor.

How do I set Anaconda's python as my default python command?

I have both Anaconda and Python 2.7 installed on my Windows machine. Right now the command "python" points to Python 2.7, but I'd like instead for it to point to Anaconda's python. How do I set this up?
Your PATH is pointing to the original Python executable. You have to update your PATH.
(Assuming Windows 7)
Right-click on Computer, the Properties, the Advanced system settings, then click the Environment Variables... button.
The lower window has the system variables. Scroll down until you find Path, select it, and click edit. In the screen that appears, update the path that is pointing to your original python.exe to the one that is in the anaconda path.
Close any open command window for update to take effect.
From the docs (https://docs.anaconda.com/anaconda/user-guide/
source <path to conda>/bin/activate
conda init
"
Should I add Anaconda to the macOS or Linux PATH?
We do not recommend adding Anaconda to the PATH manually. During installation, you will be asked “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”. If you enter “no”, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run source /bin/activate and then run conda init.
"

Error while accessing sqlite3 shell from django application

When I run python manage.py dbshell command I get this error:
Error: You appear not to have the 'sqlite3' program installed or on your path. The solution is partly hinted at in the second post of this thread. But how it can be solved on ubuntu? The python I'm using is version 2.6.
Installing the sqlite program should solve the problem:
sudo apt-get install sqlite3
(or use synaptic if you prefer a GUI interface)
To download SQLite, you open the download page of the SQlite website.
First, go to the https://www.sqlite.org website.
Second, open the download page https://www.sqlite.org/download.html
SQLite provides various versions for various platforms e.g., Windows, Linux, Mac, etc. You should choose an appropriate version to download.
For example, to work with SQLite on Windows, you download the command-line shell program as shown in the screenshot below.
The downloaded file is ZIP format and its size is quite small.
Install SQLite
Installing SQLite is simple and straightforward.
First, create a new folder e.g., C:\sqlite.
Second, extract the content of the file that you downloaded in the previous section to the C:\sqlite folder. You should see the sqlite3.exe is in the C:\sqlite folder.
To verify the installation, you perform the following steps:
First, open the command line window and navigate to the C:\sqlite folder.
Second, enter sqlite3, you should see the following window
Third, you can type the .help command from the sqlite> prompt to see all available commands in sqlite3.
Fourth, to quit the sqlite>, you use .quit command as follows:
Append the directory where you installed the sqlite to the system path variable in windows environment variables and kaboom. Mine worked just fine.
Happy programming...!