I would like to use PyInstaller to create a Windows executable. I installed pyinstaller using pip, as well as the correct version of pywin32.
When I attempt to verify the pyinstaller installation by typing pyinstaller --version, I get the message failed to create a process.
What am I doing wrong? Thanks in advance for your help.
There could be two reasons:
1) The python install location has spaces. See the answer at https://stackoverflow.com/a/34546220/3559967
2) You renamed the python install location. See the answer at https://stackoverflow.com/a/17560177/3559967
You can always reinstall pyinstaller:
python -m pip uninstall pyinstaller
[output of uninstall]
python -m pip install pyinstaller
where python is the command you use to run the python version of your choice (py, python, python3, etc.).
Notes:
Moving or changing exe names (i.e. the python.exe filename), folders, etc. can cause issues, per the other answer. If you want to make changes to the python exe or it's location, you typically need to do that immediately upon install, before installing any other packages.
There are ways of recording all your existing packages (See PIP Freeze) to a requirements.txt file, and then reinstalling them later, for another version of Python or to a new virtual environment.
If you are not familiar with virtual environments, you can start learning in the Python venv package docs. Note that you should never rename or move a venv folder after creating it (but it's easy to create a new one and reinstall the packages).
Related
I have python 3.9 I used the command 'pip install auto-py-to-exe' and it downloaded but when I tried to using the command 'auto-py-to-exe' the program just said " 'auto-py-to-exe' is not recognized as an internal or external command, operable program or batch file.". I have the latest version of PIP and I also have PATH. What can I do to fix this?
This works on VSCode:
python -m auto_py_to_exe
If I install "auto-py-to-exe" using following command, as described in this link as well as from the comment from Justin Ezequiel (above):
python -m pip install auto-py-to-exe
I am able to run it (in Windows 10) using following command:
python -m auto_py_to_exe
This gave me quite a bit of trouble, as none of the above solutions worked for me. Spent lots of time trying to figure out what I should be adding to PATH with no success.
My issue stemmed from (I think) the fact that I have been using python downloaded from the windows store, which uses a different location to store python in.
With the manual install of python (https://www.python.org) you can specify where python is downloaded and automatically add that location to path.
Steps I took to solve the problem:
Uninstall all versions of python downloaded from the windows store via settings (settings > apps > python > uninstall)
Uninstall all version of python via the control panel (control panel > add or remove programs > python x.x.x > uninstall)
Uninstall auto-py-to-exe (pip uninstall auto-py-to-exe) in case it didnt do that automatically
Install python from python.org. (auto-py-to-exe is not supported in versions greater than 3.10 as of 1/23/2023). So I installed Python 3.10
The settings which were successful for me were:
Custom installation,
check install python for all users,
check add to path,
input 'C:\Python310' (with the respective version number) for install location,
install
Check new python version has been installed python --version
Check pip is installed pip --version
Install auto-py-to-exe pip install auto-py-to-exe
When auto-py-to-exe finishes installing, scroll up through the install info and make sure there are no warnings that state there is a location not found in PATH. If there are, you'll have to do some other research on adding those locations to PATH appropriately (since I don't think I was doing that right).
Assuming no PATH warnings,
9. Run auto-py-to-exe
First you need to type in the terminal (not Python):
auto-py-to-exe
If you are currently in python use exit() to exit then try the above code.
It Depends on in which environment you have installed
Make sure to replace {User} with your user
In Conda Enviournment go to below location Manually
C:\Users\{User}\anaconda3\Scripts\auto-py-to-exe.exe
In Pip, Environment go to the location below
C:\Users\{User}\AppData\Local\Programs\Python\Python37-32\Scripts\auto-py-to-exe.exe
or you can add this path to your environment variable as well for accessing these from anywhere
First check you installed it
pip install auto-py-to-exe
then restart your vscode and check another time.
If still an error, check it in CMD.
As suggested above use:
pip show --files auto-py-to-exe to find out in what directory pip has
installed the scripts. Double check the directory is in %PATH%
This will show you where the installer has placed the binary files. I then changed to that directory which circumvents any path issue. I tried to run the files and found :
OSError: [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\aaaa\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'
PS C:\users\aaaa\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\Scripts>
In my case, although I haven't worked out how to fix it yet... It would seem to be trying to refer to an incorrect Python executable, the files in that directory are all 0 length. Unfortunately the "python -m" suggestion didn't work for me, so it's back to the drawing board. Hope that helps you confirm if it's the right solution to chase down.
You need to make sure you have typed cd C:\Users\your_user_name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts as a separate command, and then auto-py-to-exe with python 3. Check in file explorer to make sure your path is correct if the cd fails.
I have python 3.9 I used the command 'pip install auto-py-to-exe' and it downloaded but when I tried to using the command 'auto-py-to-exe' the program just said " 'auto-py-to-exe' is not recognized as an internal or external command, operable program or batch file.". I have the latest version of PIP and I also have PATH. What can I do to fix this?
This works on VSCode:
python -m auto_py_to_exe
If I install "auto-py-to-exe" using following command, as described in this link as well as from the comment from Justin Ezequiel (above):
python -m pip install auto-py-to-exe
I am able to run it (in Windows 10) using following command:
python -m auto_py_to_exe
This gave me quite a bit of trouble, as none of the above solutions worked for me. Spent lots of time trying to figure out what I should be adding to PATH with no success.
My issue stemmed from (I think) the fact that I have been using python downloaded from the windows store, which uses a different location to store python in.
With the manual install of python (https://www.python.org) you can specify where python is downloaded and automatically add that location to path.
Steps I took to solve the problem:
Uninstall all versions of python downloaded from the windows store via settings (settings > apps > python > uninstall)
Uninstall all version of python via the control panel (control panel > add or remove programs > python x.x.x > uninstall)
Uninstall auto-py-to-exe (pip uninstall auto-py-to-exe) in case it didnt do that automatically
Install python from python.org. (auto-py-to-exe is not supported in versions greater than 3.10 as of 1/23/2023). So I installed Python 3.10
The settings which were successful for me were:
Custom installation,
check install python for all users,
check add to path,
input 'C:\Python310' (with the respective version number) for install location,
install
Check new python version has been installed python --version
Check pip is installed pip --version
Install auto-py-to-exe pip install auto-py-to-exe
When auto-py-to-exe finishes installing, scroll up through the install info and make sure there are no warnings that state there is a location not found in PATH. If there are, you'll have to do some other research on adding those locations to PATH appropriately (since I don't think I was doing that right).
Assuming no PATH warnings,
9. Run auto-py-to-exe
First you need to type in the terminal (not Python):
auto-py-to-exe
If you are currently in python use exit() to exit then try the above code.
It Depends on in which environment you have installed
Make sure to replace {User} with your user
In Conda Enviournment go to below location Manually
C:\Users\{User}\anaconda3\Scripts\auto-py-to-exe.exe
In Pip, Environment go to the location below
C:\Users\{User}\AppData\Local\Programs\Python\Python37-32\Scripts\auto-py-to-exe.exe
or you can add this path to your environment variable as well for accessing these from anywhere
First check you installed it
pip install auto-py-to-exe
then restart your vscode and check another time.
If still an error, check it in CMD.
As suggested above use:
pip show --files auto-py-to-exe to find out in what directory pip has
installed the scripts. Double check the directory is in %PATH%
This will show you where the installer has placed the binary files. I then changed to that directory which circumvents any path issue. I tried to run the files and found :
OSError: [WinError 1920] The file cannot be accessed by the system: 'C:\\Users\\aaaa\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\python.exe'
PS C:\users\aaaa\appdata\local\packages\pythonsoftwarefoundation.python.3.7_qbz5n2kfra8p0\localcache\local-packages\python37\Scripts>
In my case, although I haven't worked out how to fix it yet... It would seem to be trying to refer to an incorrect Python executable, the files in that directory are all 0 length. Unfortunately the "python -m" suggestion didn't work for me, so it's back to the drawing board. Hope that helps you confirm if it's the right solution to chase down.
You need to make sure you have typed cd C:\Users\your_user_name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts as a separate command, and then auto-py-to-exe with python 3. Check in file explorer to make sure your path is correct if the cd fails.
I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?
I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.
You should open the terminal inside the VSCode and install the modules you want.
something like👇
if that's not you meant, please let me know.
First of all I would advise you to select the current Python version you have. It has been explained here:
VSCode: There is no Pip installer available in the selected environment
Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:
https://pip.pypa.io/en/stable/installing/
or this thread
How to use pip with Visual Studio Code
by typing
py -m pip
in your terminal, like
C:\Users\m\Desktop\Python> py -m pip
You should have the list of commands and general options which can be used. One of them is install
On the Python library platform, you always have the command to be copied in order to the installation of package you want.
In your terminal, the initial command should look as:
PS C:\Users\m\Desktop\Python> py -m
to which you should append the command prepared on the Python library platform (by copying it and pasting).
C:\Users\m\Desktop\Python> py -m pip install openpyxl
That's it. The package should be installed in your Python folder, what you will see in the terminal.
If everything is alright, you just need to type
import openpyxl #or other package name, which you downloaded
and use it!
Unfortunately! for now, only possible way is terminal.
I'm wanting to learn machine learning, but it requires that I use 'pip.' I'm still very new to a lot of this stuff. I've installed Python 3.4 64-bit and get-py.py.
When I run pip install sklearn I get 'pip' is not recognized as an internal or external command, operable program or batch file.
Here's a screenshot of my environmental variable PATH
https://gyazo.com/c7ec926401878845d5c4f9a556cf00ee
Any help would be greatly appreciated. I have checked out other posts where people had similar issues, but I tried various things and nothing worked.
Easiest solution is to just download a platform like Anaconda for example. It is Python with many libraries (sklearn, pandas, numpy, ...) and also with pip, all in a user-friendly Windows installer package, that takes care of everything for you.
https://www.continuum.io/downloads
If you really want to do it yourself, then
download get-pip.py (https://bootstrap.pypa.io/get-pip.py)
make sure you have Python installed and in your PATH, for example by running python --version in command prompt
Navigate to the directory, where you downloaded get-pip.py (in command prompt using the command cd).
Run the command python get-pip.py from a command prompt with admin privileges (possibly not needed, but just to make sure).
This should be all. Close your command prompt, open it again and run pip --version to test it. If it doesn't work, then search your computer for a file named pip.exe (most likely in your Python directory) and if you find it, add its path to your PATH variable (given the screenshot, I assume you know how to do this).
I downloaded Python 3.6 and the pip was installed on my system.
I found pip at below location:
C:\Users\Admin\AppData\Local\Programs\Python\Python36\Scripts
Also, before I found pip I used below command on my command prompt to install pyperclip:
python -m pip install pyperclip
For anyone that might have installed Python using the MSI installer, and ticked the box to include pip, but still gets the error 'pip' is not recognized as an internal or external command, operable program or batch file:
It looks like that the pip executable is installed in the \Scripts subdirectory of the Python installation, but that directory does not get automatically added to PATH.
For me, since I had installed Python 2.7, the directory was C:\Python27\Scripts. After adding this path to the PATH environment variable, and open a new CMD window, pip was available as a command.
I've made a workaround that will help you, copy the batch script below and modify it as specified:
#"PATH to python.exe" "PATH to pip.exe" %*
For example like this:
#"C:\programming\bin\python374\python.exe" "C:\programming\bin\python374\Scripts\pip.exe" %*
Save this file as pip.bat on Desktop and then move it to C:\Windows\system32.
For Python 3.7 or higher at least (as today is October 4th 2019) in the installation window you need to check the box "add to PATH" when you first install Python.
I'm late now, but just add python to your environment variables.
It´s explained in this short video, how to set up python to your environment variables:
https://www.youtube.com/watch?v=Y2q_b4ugPWk
after that pip should work on your cmd prompt, without cd to
"C:\Users\Admin\AppData\Local\Programs\Python\Python36\Scripts"
This is late but in case anyone runs across this issue, pip installed for me as "pip3". Once I used pip3 as my command and not pip, it worked fine. Threw me for quite a loop since I've been using Python for years.
PIP Install and Upgrade
Ensure you are accessing the right location while accessing pip as shown in my link above. Starting Python 3.4, it is included by default with the Python binary installers.
Environment Variable
It is also a good idea to update the environment variable if the path is not accessible by default, once the installation is complete.
If it is specifically pip you want you could install python again making sure to tick the install pip box which it sounds like you failed to upon initial installation.
I am running Windows and am a beginner python user trying to install a few modules to run a python script. I have Python 2.7.9 and 3.4.2 both installed to the C:\ directory. I downloaded matplotlib-1.4.3.win-amd64-py3.4.exe and the corresponding .exe for python 2.7 from the Matplotlib website, but when I run the py3.4 exe the program cannot find Python 3.4 to update (Cannot install: Python version 3.4 is required, which is not found in the registry).
Python 2.7 installer works perfectly. Is there a misset PATH variable in Windows I can modify so the .exe can function properly? In CMD 'Python --version' returns Python 3.4, so unsure how to fix the issue. I installed these months ago, and may have put them in Downloads before transferring both to C:\ for clarity, which may be the problem but am unsure how to fix it.
Also, if your answer involves pip in any way please clarify how exactly to use pip in Windows. A lot of websites say to run eg. 'pip setup.py install' in the 'terminal' but do not specify if they mean Windows CMD terminal, IDLE GUI, or Python.exe command-line interface. Thanks a lot!
Not the answer to your actual question, but some clarification on your last point:
but do not specify if they mean Windows CMD terminal, IDLE GUI, or
Python.exe command-line interface.
Yes, this requires to know some context that a beginner may not have. The command pip is always used in the CMD terminal. So open CMD, and enter
pip3 install matplotlib
Notes:
Use pip3 when installing for Python 3. Then you're certain you're not accidentally installing libraries for Python 2.
pip setup.py install does not exist. You're mixing up two mechanisms to install Python packages/libraries:
One uses pip, with aforementioned pip3 install <something>. Pip goes looking online, finds a corresponding package name in a database, retrieves the URL for that package, downloads the package and installs the package. All in one command.
python3 setup.py install (again explicitly use python3 or python2 to be sure) requires you to find the package, download it, unzip it, and then in the CMD terminal, inside the unzipped folder, run the python3 setup.py install command.
This second method is usually for the latest-greatest version of a package that is not yet in pip's database, or for packages that never were in pip's database in the first place.
Generally, as a beginner, you want to stick with pip. If you ever run into the issue with the package not being available via pip, you may still be able to use pip for downloading and installing, like for example so:
pip install https://github.com/matplotlib/matplotlib/archive/master.zip
which would install the most recent matplotlib (which won't have even a version number yet, so bugs could be around).
All of these commands happen in the CMD terminal: downloading/installing packages generally all go through the terminal.
Also, when people mention "terminal", they will mean (for Windows) something like the CMD terminal. When it has to be done inside Python, it is generally called the "Python prompt". (IDLE is yet a different beast, that I'm not familiar with. I'm guessing that it has several parts, including a text editor section and a Python prompt section.)