I am having issues with getting pyinstaller version 3.6 to work to make my application executable. The crux of my problem is that pyinstaller is not compatible with python 3.8, but when I check python --version on my terminal it confirms I have python 3.7. However, when I check my pip path it gives me pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8). Also, I am currently using VScode as my editor, and when I check sys.version_info in my app script it gives me version 3.8 as well. I tried creating a virtual environment in new file, double checking the package.json with 3.7, but when I run sys.version_info it still gives me 3.8 (I am still a beginner at using shell/terminal so I am confused as to why since my python version is 3.7 on my shell).
I worried about doing a complete uninstall of python and pip since I've read it could mess up the paths and cause complications repairing. How can I change the pip path to python 3.7 or have my script run 3.7 so that I can use pyinstaller on my macOS?
Related
I had a Python 3.9 installed on my Windows 10 machine and it had a lot of issues, so I had to upgrade it to Python 3.10
I uninstalled Python 3.9 from my machine, and installed 3.10, and added it to PATH.
I also had a Python 3.7 instance as well.
Now after installing Python 3.10, pip and virtualenv are not working anymore, when I try to install virtualenv using pip, I get this error:
Fatal error in launcher: Unable to create process using '"c:\users\wwwwww\appdata\local\programs\python\python37\python.exe" "C:\Users\wwwww\AppData\Local\Programs\Python\Python37\Scripts\pip.exe" install virtualenv': File not found
Even after uninstalling Python 3.9, I can still see 3.7 and 3.9 on my machine:
When I try python on my Visual Code terminal, I get the shell and everything works fine:
But when I try to run it on Git Bash, I get nothing, and the terminal crashes:
I want to reset everything and remove all python and pip so I can start from scratch and continue my work because I'm blocked right now.
The problem is with Windows 10 and their decision to automatically enable Python as an execution alias, and thus impacting the command line behavior.
To solve this issue, simply go to Windows Parameters -> Apps and Features, and search: Manage Apps Execution Aliases.
Uncheck every Python mention in the list:
And now the problem is solved:
which pip3:
/Library/Frameworks/Python.framework/Versions/3.8/bin/pip3
python version in notebook:
import platform
print(platform.python_version())
3.9.2
I want my jupyter notebook to run on python 3.8.
NOTE: I'm intentionally avoiding conda for this exercise.
Jupyter is installed into a particular Python environment like any other Python module. If Jupyter is running under Python 3.9, then you're running the version of it that was installed by the pip in Python 3.9. It might be installed in the base 3.9 implementation, or it could be installed in a virtual environment that is based on Python 3.9.
If you want a Jupyter that is running under Python 3.8, then you need to run the version of it that is installed under Python 3.8 or a virtual environment based on 3.8. If no such version exists, then you need to install it using Python 3.8 pip. Once installed, you need to run that version of it. You can always do that by specifying the full path to the appropriate jupyter binary. But that is, of course, not ideal...
Which version you get when you run just jupyter is a function of your PATH and/or any Python package manager you might be running. I use pyenv, and that tool will set it up so that for the Python version I've chosen to be the current global version, that version's (or virtual environment's) bin directory becomes the first Python bin directory in my PATH. So if I type jupyter, I always run the version that is installed in what pyenv has made the current global Python environment.
I am a little confused about Python installations, configurations and interpreter locations.
I am using Ubuntu 20.04 and I have been using Pycharm for some time, installed both Python 2.7 and Python 3.8 (even though I am not sure where I installed both...).
Now I started a project with Pycharm that uses some specific packages that I included in the requirements.txt file. Every time I open Pycharm it asks me to install those packages (Package requirements 'numpy~=1.16.6', 'scipy~=1.5.1' are not satisfied. Install requirements/Ignore requirements), I do it and the next time I get the same request.
If I try to set up a Python interpreter through the GUI of Pycharm I get the following options:
Project Default (Python 2.7) /usr/bin/python
Python 2.7 /usr/bin/python
Python 3.8 (OldProject) ~/Workspace/OldProject/venv/bin/python
Python 3.8 (OldProject2) ~/Workspace/OldProject2/venv/bin/python
How can I change the system default Python to version 3.8?
If I run on the terminal:
python --version
I get
Python 3.8.2
So why is Pycharm displaying Python 2.7 as Project Default? And why there's no Python 3.8 system installation among the options?
You can change your Pycharm python interpreter by going in to File -> Settings and than search python interpreter at the search input.
The command line python version is the one that the "Path" envirment variable refer too (the file python.exe in the relevent python folder)
I want to create a virtual environment with python version 2.7 on windows, however, after installing virtualenv and running python 2.7 -m venv project
I am receiving an error RuntimeError: failed to find interpreter for Builtin discover of python_spec='2.7'
I have downloaded the 2.7 version of python as well, what am I missing?
venv is a package that was only introduced from python 3.3 and above.
( https://docs.python.org/3/library/venv.html )
I never used it.
You might use virtualenv, that exists also for python 2.7. but must be installed with following command (but you did this probably already)
py -2.7 -m pip install virtualenv
You then type
py -2.7 -m virtualenv project_dir
if none of above works, then please type
py -2.7 -m pip freeze and post the output.
You can also type
py -2.7 -c "import sys ; print(sys.executable, sys.version_info)"
To see what python 2.7 version you have exactly installed.
The difference between py.exe and python.exe:
On windows py.exe is the python launcher, that tries to keep track of all installed python versions and of potentially activated virtualenvs and launches the one you want.
python will try to find the python executable in the search path.
and it would yield the first python in the path.
py is the windows python launcher which will locate the python executables with help of environment variables and the registry and which allows with the -version (e.g. -2.7) switch to select which version of python you want to call.
( Documentation for the python launcher on windows:
https://docs.python.org/3/using/windows.html#from-the-command-line )
I am trying to convert a .py file to an exe. My file, hello.py, reads:
print "Hello, World!"
I am currently trying to use pyinstaller. However when I run the command
pyinstaller hello.py
I get the error message "tuple index out of range" which I have been told means my version of python is unsupported. In particular it would seem the situation is that pyinstaller thinks I am trying to compile python 3.6 code into an exe. But I have python 2.7 and python 3.6 installed. How do I let it know that I want it to regard the code as python 2.7 code?
Using Python3:
Make sure PyInstaller is installed in Python 3.x: pip3 freeze
PyInstaller==3.3.1
Then running the command:
/path/to/python3 -m PyInstaller your_script.py
First install Pyinstaller in your python2.7 version if not installed previously
py -2 -m pip install pyinstaller
and then go to your folder and
py -2 -m pyinstaller -F filename.py
When you need to bundle your application within one OS but for different versions of Python and support libraries – for example, a Python 3 version and a Python 2.7 version; or a supported version that uses Qt4 and a development version that uses Qt5 – we recommend you use virtualenv. With virtualenv you can maintain different combinations of Python and installed packages, and switch from one combination to another easily. (If you work only with Python 3.4 and later, python3 -m venv does the same job, see module venv.)
Use virtualenv to create as many different development environments as you need, each
with its unique combination of Python and installed packages.
Install PyInstaller in each environment.
Use PyInstaller to build your application in each environment.
The answers have devolved in "How do I tell pyinstaller which python version to use?" So, I know that this doesn't really answer the original question. However, I wasted about an hour trying to figure this out so, in the hopes that others don't have to waste an hour... To force pyinstaller to use Python 3.9 under Windows do the following.
Given Windows and Python 3.9:
python3.9 -m PyInstaller [whatever options you want]
You have to type it as PyInstaller instead of pyinstaller (i.e. note the capitalization).
python3.9 -m pyinstaller
Produces an error:
C:\Users\chris.SR\AppData\Local\Programs\Python\Python39\python.exe: No module named pyinstaller
Supposing you have python 2.x on the path under python2 you can do
python2 -m pyinstaller hello.py
I ran two a couple things.
If you uninstall python3, it works with python2.
If you have python3 installed (and it is the primary), and have pyinstaller installed in python3, it wont work (python3 pyinstaller used).
If you have python3 installed, but do not have it installed in python3 or uninstalled it (pip3 uninstall pyinstaller), pyinstaller works.
Checking the environmental variables (windows 10) PATH had python3 first. This may be the issue and may not be resolved because it is checking python3 directories first, and picks up pyinstaller for python3. pyinstaller does not check the file either (#!/usr/env/bin python2).
Unless pyinstaller puts an option relating to this issue, there may be no solution short of uninstalling pyinstaller from python3 temporarily.
note
could also use py2exe, using py2exe for python2, pyinstaller for python3