How to create an executable with a pycharm python file though pyinstaller? - python

I have been trying to install pyinstaller in order to create an executable of a python project I have been working on, but my pip command simply doesn't work. This is the error I would get "'pip' is not recognized as an internal or external command, operable program or batch file". I have already checked the interpreter of my pycharm project, and it shows that it has pip already installed. I tried to look this up online, and I found out that a problem could be that the environment variable Path just needs to have the directory of my python version, but even after doing this, it still would not work. For additional information, I already tried to find the directory by using the command "where python" in the command prompt, but that path didn't work, and I'm using windows 10.

Usually for most of users, there would be a problem as you mention above. In such situation, you just need to install pip again with command like
python -m pip3 install -U pip
and remember next time, if pip reminds you to upgrade it, do not just use
pip install -U pip

Related

how to fix 'auto-py-to-exe' is not recognized as an internal or external command, operable program or batch file

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.

PIP not present in Python 3.8 for Windows

I read in the PyPa pip documentation that pip comes with Python versions above 3.4 . Meanwhile when I run the 'pip help' command on my command prompt it gives me the message below:
'pip' is not recognized as an internal or external command,
operable program or batch file.
I tried executing a suggested command from a response to a similar question yielding this:
Looking in links: c:\Users\Public\Documents\Wondershare\CreatorTemp\tmpdgjv05zc
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0
I ran 'pip' help again yet again it gave me the same tone-deaf message
'pip' is not recognized as an internal or external command,
operable program or batch file.
I can run Python files and 'py --version' gives me the version of Python I'm using. I also tried placing the 'get-pip.py' file in a folder and getting to it through command prompt. Then I executed these commands
C:\Users\User\Desktop\pyt>python get-pip.py
C:\Users\User\Desktop\pyt>py get-pip.py
C:\Users\User\Desktop\pyt>python3 get-pip.py
They were executed immediately one-after-another but now no messages appear on the screen . Instead the OS goes to the next line, ignoring my command as if I didn't already execute one.
Why is it that I don't have pip installed? How can I install it?
Typically, when installing Python, if you add it to the PATH system environment variable, both the Python3x (containing the Python executable) and the Python3x\Scripts (containing pip) folders will be added to your path.
Apparently, something has happened to your path causing only the first of those two to be on the path.
Check which Python is on the path by running where python from the command line. If that's the version of Python you expect to be using, add the Scripts folder for the same version to the path as well.
Alternatively, uninstall your version of Python and then reinstall, ensuring you check it so it adds Python to the PATH - at the end of the Windows installation, there's the option to lift PATH length restrictions, which may be your issue.
Likely you didn't add your python installation to your path (here's a how-to guide if you've never done this before). If you are on windows then add %USERPROFILE%\AppData\Local\Programs\Python\Python38\Scripts\ to your path. Change the 38 to whichever point release you installed (so if you installed python 3.7 then it would be 37 etc.).

How do I use pip install?

When I look up tutorials on Python almost every one starts with "Start of with pip install bs4" but they never tell me about how. Because when I write "pip install bs4" in my cmd the answer I get is only
'pip' is not recognized as an internal or external command,
operable program or batch file.
I've tried running "pip install bs4" in PyCharm as well but nothing works.
I am a totally a beginner, which you probably already noticed, and just want to get beautifulsoup.
I'm going to assume you're on Windows since your error message contains "batch file". Try:
py -m pip install bs4
The -m flag will import the pip module, and allow you to run the install command. If running py doesn't work, try the absolute path to your python.exe.
This is the official site that shows you how to download and install python pip
pretty much just download the file, open up the command prompt, cd to file directory and run it with:
python get-pip.py

I can't use pip (Windows)

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.

How to install packages with pip in Windows PowerShell

I am using Python 2.7.9 on a Windows 8 computer.
I tried to install lxml by typing pip install lxmlin Windows PowerShell after typing python, but I get the following error: SyntaxError: invalid syntax
I tried installing pip by using the following tutorial http://www.tylerbutler.com/2012/05/how-to-install-python-pip-and-virtualenv-on-windows-with-powershell/ only to later realize that I already had pip.exe, pip2.7.exe and pip2.exe installed when I first installed Python. They are located in the C:\Python27\Scripts directory.
Yet, if I try something like pip help I will get an invalid syntax error.
Do I have to reinstall pip or how do I get it to work in order to install the lxml library.
Thank you for any help you can provide.
I had the same problem. You need to set the PATH environment variable, so that the system recognizes the command "pip".
If typing easy_install or pip [in PowerShell] doesn’t work, it means the Scripts folder is not in your path. Run the next command in that case (Note that this command must be run only once or your PATH will get longer and longer). Make sure to replace c:\Python33\Scripts with the correct location of your Python installation:
setx PATH "%PATH%;C:\Python33\Scripts"
Close and reopen PowerShell after running this command.
Source: http://arunrocks.com/guide-to-install-python-or-pip-on-windows/
Starting from Python versions 2.7.9 and 3.4.0, 'pip' is already included in the regular install. Check if the path to the 'Scripts' directory inside your Python installation directory is contained in your system's 'PATH' environment variable, so 'pip' can be found.
Look here for more information:
How do I install pip on Windows?
Edit: Sounds like you are trying to run pip inside python, You shouldn't get an 'invalid syntax' error through the command prompt. More like "'pip' is not recognized". Try simply just opening command prompt and typing 'pip help'

Categories

Resources