I'm new to python, and I was wondering if you could help me run a python script. I'm trying to run a script called PunchBox from Github: https://github.com/psav/punchbox. So far, I have Python 3.9.5 and Git Bash.
In the GitHub page, it says:
To install, clone the repo, cd into it and then execute the following:
virtualenv -p python2 .pb2
source .pb2/bin/activate
pip install -U pip
pip install .
What does this mean exactly? Where do I run this code?
So far, I tried downloading the zip file from GitHub, installing Python 3.5.9, using cmd, finding the directory with cd, and running that code; but got an error:
Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.
error in punchbox setup command: Error parsing C:\Users\Mi\Downloads\punchbox-master\punchbox-master\setup.cfg: Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name punchbox was given, but was not able to be found.
There's also a requirements.txt that lists additional scripts needed:
pre-commit
click
mido
pbr
PyYAML
svgwrite
Do these install automatically upon running the script for the first time?
I'm a little confused why I'm getting an error. Do you know what I'm doing wrong?
Thank you so much!
Giovanni
I assume you are new to programming. You have to write these lines in a terminal.
On Windows, it is Command Prompt or PowerShell Applications (latter preferred). On macOS, it is terminal
Copy all these lines at once, and paste them to your preferred terminal. The terminal will automatically run these one after the another.
FYI: Venv is a python package to create a virtual environment. The preceding commands set up the environment. Now install the required dependencies using this command instead of the last command (pip install .)
pip install -r requirements.txt
Based on your comment, it looks like you don't have virtualenv installed in your system. You may install it using the command pip install virtualenv.
Now, as you are using a Windows machine, you may open a Command Prompt or Windows PowerShell window and navigate to the directory where your cloned project resides.
Now, execute the following commands.
virtualenv -p python2 .pb2
.pb2\Scripts\activate.bat
pip install -U pip
pip install -r requirements.txt
Once you are done working in your virtual environment (which is named .pb2), you may close it by executing deactivate command.
#Giovanni T.
See, as far as you have installed Python and also downloaded the GitHub Repository as a zip file.
pip install -r requirements.txt
Just run this command.
Please make sure that the directory is pointing to the folder where this requirements.txt file is stored.
I created a python 3.3 app on RedHat's Openshift cloud service. By default it has setup.py for my project. I'm learning Udemy course called "Build a SaaS app with Flask" (source code) Now I wanted to use python-click, as recommended by the course. It needs another setup.py for cli project; so to put that file in the project root folder, I renamed it to setup_cli.py. Now there are two files: setup.py and setup_cli.py.
Pip install seems to automatically look into setup.py.
# See Dockerfile in github source
pip install --editable <from setup_cli.py>
Can pip install --editable be used to point to setup_cli.py?
It seems that you can't do anything about it :-) - It's hard coded in pip source code :-)
If you try to use pip install -e ., it will call a method named parse_editable which will run this line:
if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
raise InstallationError(
"Directory %r is not installable. File 'setup.py' not found." %
url_no_extras
)
You may want to to use this command pip install -e file:///full/path/to/setup_cli.py, but this command also appends a hard coded setup.py to your path :-)
In setup_py there is this line:
setup_py = os.path.join(self.setup_py_dir, 'setup.py')
so as #cel commented, it seems that python <whatever-setup.py> develop is your only option.
When I type ipython notebook it works fine. However I need to work into a virtual environment:
What I do
virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
Now I type
ipython notebook
This given the error:
/home/derk/assignment2/.env/bin/python: bad interpreter: No such file or directory
So when not in the virtual environment I can start the notebook. However, when not into the virtual environment it gives an error.
The requirements.txt looks like this:
Cython==0.21.2
Jinja2==2.7.3
MarkupSafe==0.23
Pillow==2.7.0
backports.ssl-match-hostname==3.4.0.2
certifi==14.05.14
gnureadline==6.3.3
ipython==2.3.1
matplotlib==1.4.2
mock==1.0.1
nose==1.3.4
numpy==1.9.1
pyparsing==2.0.3
python-dateutil==2.4.0
pytz==2014.10
pyzmq==14.4.1
scipy==0.14.1
six==1.9.0
tornado==4.0.2
wsgiref==0.1.2
Everything worked correctly before, but now (maybe after some software updates) it doesnot. I tried reinstalling Anaconda (as suggested on some sites), but without success. What could be the problem here?
This error can happen when one has moved or renamed the virtualenv. In my case, the folder was moved to another user(mint -> emil), but otherwise had the same path. To solve it one can edit the configuration files, see this answer. In my case, python worked fine within the virtualenv, but ipython did not:
(env) emil#emil-VirtualBox ~/X/X $ ipython
bash: /home/emil/X/env/bin/ipython: /home/mint/X/env/bin/python3.5: bad interpreter: No such file or directory
Checking which file was run:
(env) emil#emil-VirtualBox ~/X/env/bin $ which ipython
/home/emil/X/env/bin/ipython
Did not indicate a problem. I browsed into the folder and the file was there. So it wasn't missing. Then I remembered that I had had to edit some files after moving the virtualenv earlier. One has to edit the 'bash header' (sha-bang) in all the important files. In my case, these were:
activate
pip
ipython
I.e., find the header which looks like:
#!/home/mint/X/env/bin/python3.5
and change to:
#!/home/emil/X/env/bin/python3.5
Searching the net this seems to be a problem caused by spaces in the Python installation path.
How do I get pip to work without having to reinstall everything in a path without spaces ?
it seems that
python -m pip install XXX
will work anyway (worked for me)
(see link by user474491)
On Windows at least, pip stores the execution path in the executable pip.exe when it is installed.
Edit this file using a hex editor or WordPad (you have to save it as plain text then to retain binary data), change the path to Python with quotes and spaces like this:
#!"C:\Program Files (x86)\Python33\python.exe"
to an escaped path without spaces and quotes and pad with spaces (dots at the end should be spaces):
#!C:\Progra~2\Python33\python.exe.............
For "C:\Program Files", this path would probably be "C:\Progra~1" (shortened path names in DOS / Windows 3.x notation use tilde and numbers).
Windows provides this alternative notation for backwards compatibility with DOS / Windows 3.x apps.
Note that as this is a binary file, you should not change the file size which may break the executable, hence the padding.
Save with administrator privileges, make sure it is actually saved at the target location and try again.
You might also need to set the PATH variable to use the ~ notation for the path to pip.
having the same trouble I read in https://pip.pypa.io/en/latest/installing.html#install-pip that to update pip it's:
python -m pip install -U pip
So I made (for example)
python -m pip install virtualenv
And it worked! So you can do the same being 'virtualenv' another package you want.
python -m pip
really works for the problem Fatal error in launcher: Unable to create process using '"'.Worked on Windows 10
I had a similar issue and upgrading pip fixed it for me.
python -m pip install --upgrade pip
This was on Windows and the path to python inside pip.exe was incorrect. See Archimedix answer for more information about the path.
Here's how I solved it:
open pip.exe in 7zip and extract __main__.py to Python\Scripts folder.
In my case it was C:\Program Files (x86)\Python27\Scripts
Rename __main__.py to pip.py
Run it! python pip.py install something
EDIT:
If you want to be able to do pip install something from anywhere, do this too:
rename pip.py to pip2.py (to avoid import pip errors)
make C:\Program Files (x86)\Python27\pip.bat with the following contents:
python "C:\Program Files (x86)\Python27\Scripts\pip2.py" %1 %2 %3 %4
%5 %6 %7 %8 %9
add C:\Program Files (x86)\Python27 to your PATH (if is not already)
Run it! pip install something
This is a known Bug when there is a space in the virtualenv path. Correction has been made, and will be available in the next version.
i had same issue and did a pip upgrade using following and now it works fine.
python -m pip install --upgrade pip
I renamed the executable of python.exe to e.g. python27.exe. In respect to the answer of Archimedix I opened my pip.exe with a Hex-Editor, scrolled to the end of the file and changed the python.exe in the path to python27.exe. While editing make shure you don't override other informations.
I wrote a script to patch those exe. But the best way is to fix distutil itself.
"""Fix "Fatal error in launcher: Unable to create process using ..." error. Put me besides those EXE made by pip. (They are made by distutils, and used by pip)"""
import re
import sys
import os
from glob import glob
script_path = os.path.dirname(os.path.realpath(__file__))
real_int_path = sys.executable
_t = script_path.rpartition(os.sep)[0] + os.sep + 'python.exe'
if script_path.lower().endswith('scripts') and os.path.isfile(_t):
real_int_path = _t
print('real interpreter path: ' + real_int_path)
print()
for i in glob('*.exe'):
with open(i, 'rb+') as f:
img = f.read()
match = re.search(rb'#![a-zA-Z]:\\.+\.exe', img)
if not match:
print("can't fix file: " + i)
continue
int_path = match.group()[2:].decode()
int_path_start = match.start() + 2
int_path_end = match.end()
if int_path.lower() == real_int_path.lower():
continue
print('fix interpreter path: %s in %s' % (int_path, i))
f.seek(int_path_start)
f.write(real_int_path.encode())
f.write(img[int_path_end:])
I had the same issue on windows 10, after trying all the previous solution the problem persists so I decided to uninstall my python 2.7 and install the version 2.7.13 and it works perfectly.
This can happen if you are using a case-sensitive file system on Windows. You can tell if this is the case if there is both a lib directory and a Lib directory in your venv directory :
> dir
Directory: C:\git\case\sensitive\filesystem\here\venv
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/07/2018 4:10 PM Include
d----- 22/01/2019 7:52 AM Lib
d----- 22/01/2019 7:52 AM lib
d----- 22/01/2019 7:52 AM Scripts
d----- 22/01/2019 7:52 AM tcl
To workaround this (until virtualenv.py gets fixed: https://github.com/pypa/virtualenv/issues/935) merge the two lib directories and make venv case-insensitive:
cd venv
move Lib rmthis
move .\rmthis\site-packages\ lib
rmdir rmthis
fsutil.exe file setCaseSensitiveInfo . disable
Here is how i fixed it.
Download https://bootstrap.pypa.io/get-pip.py
Active your vitualenv
Navigate to the get-pip.py file and type "python get-pip.py" without quote.
it will reinstall your pip within the environment and uninstall the previous version automatically.
now boom!! install whatever you like
Please add this address :
C:\Program Files (x86)\Python33
in Windows PATH Variable
Though first make sure this is the folder where Python exe file resides, then only add this path to the PATH variable.
To append addresses in PATH variable, Please go to
Control Panel -> Systems -> Advanced System Settings -> Environment
Variables -> System Variables -> Path -> Edit ->
Then append the above mentioned path & click Save
I added my anwer because I have getting the same error while configure ODDO9 source code in local and its need the exe to run while run exe, I got the same error.
From yesterday I was configure oddo 9.0 (section :- "Python dependencies listed in the requirements.txt file.") and its need to run PIP exe as
C:\YourOdooPath> C:\Python27\Scripts\pip.exe install -r requirements.txt
My oddo path is :- D:\Program Files (x86)\Odoo 9.0-20151014
My pip location is :- D:\Program Files (x86)\Python27\Scripts\pip.exe
So I open command prompt and go to above oddo path and try to run pip exe with these combination, but not given always above error.
D:\Program Files (x86)\Python27\Scripts\pip.exe install -r requirements.txt
"D:\Program Files (x86)\Python27\Scripts\pip.exe install -r requirements.txt"
Python27\Scripts\pip.exe install -r requirements.txt
"Python27/Scripts/pip.exe install -r requirements.txt"
I resolved my issue by the #user4154243 answer, thanks for that.
Step 1: Add variable(if your path is not comes in variable's path).
Step 2: Go to command prompt, open oddo path where you installed.
Step 3: run this command python -m pip install XXX will run and installed the things.
i solve my problem in Window
if u install both python2 and python3
u need enter someone \Scripts change all file.exe to file27.exe,then it solve
my D:\Python27\Scripts edit django-admin.exe to django-admin27.exe so it done
My exact problem was (Fatal error in launcher: Unable to create process using '"') on windows 10. So I navigated to the "C:\Python33\Lib\site-packages" and deleted django folder and pip folders then reinstalled django using pip and my problem was solved.
I have chosen to install Python for Windows (64bit) not for all users, but just for me.
Reinstalling Python-x64 and checking the advanced option "for all users" solved the pip problem for me.
On Windows I had solved this problem in the following way :
1) uninstalled Python
2) navigated to C:\Users\MyName\AppData\Local\Programs(your should turn on hidden files visibility Show hidden files instruction)
3) deleted 'Python' folder
4) installed Python
this worked for me
python -m pip install --upgrade --force-reinstall pip
Try reinstall by using the below link,
Download https://bootstrap.pypa.io/get-pip.py
After download, copy the "get-pip.py" to python installed main dirctory, then open cmd and navigate to python directory and type "python get-pip.py" (without quotes)
Note: Also make sure the python directory is set in the environmental variable.
Hope this might help.
For me this problem appeared when I changed the environment path to point to v2.7 which was initially pointing to v3.6. After that, to run pip or virtualenv commands, I had to python -m pip install XXX as mentioned in the answers below.
So, in order to get rid of this, I ran the v2.7 installer again, chose change option and made sure that, add to path option was enabled, and let the installer run. After that everything works as it should.
I had this issue and the other fixes on this page didn't fully solve the problem.
What did solve the problem was going in to my system environment variables and looking at the PATH - I had uninstalled Python 3 but the old path to the Python 3 folder was still there. I'm running only Python 2 on my PC and used Python 2 to install pip.
Deleting the references to the nonexistent Python 3 folders from PATH in addition to upgrading to the latest version of pip fixed the issue.
I had a simpler solution. Using #apple way but rename main.py to pip.py then put it in your python version scripts folder and add scripts folder to your path access it globally. if you don't want to add it to path you have to cd to scripts and then run pip command.
I have similar problem when I reinstall my python, by uninstalling python3.7 and installing python3.8. But I solved it by removing the previous version of python directory. For me it was located here,
C:\Users\your-username\AppData\Local\Programs\Python
I deleted the folder named Python37 (for previous version) and keep Python38 (for updated version). This worked because python itself seems having a trouble on finding the right directory for your python scripts.
I was trying to install some site-packages like numpy, xgboost and so on, but this error showed up every time:
Fatal error in launcher: Unable to create process using
I've tried many ways to solve this problem and found this one, that successfully helped me:
python -m pip freeze
Hope it'll help someone too.
P.S. I found this solution here: https://stackoverflow.com/a/39733705/10310794
You can remove previous python folder and also environment variable path from you pc then Reinstall python .it will be solve
I had this problem when using django rest framework and simplejwt. All I had to was upgrade pip and reinstall the packages
I had this problem today. The reason I was getting the error is because I have a project stored on Dropbox that I access from 2 different computers.
I am using venv, and because I had venv setup on machine A, if I attempted to run pytest on machine B I would get the error.
Deleting the venv folder, and running python -m venv venv solved the issue for me.
Instead of calling ipython directly, it is loaded using Python such as
$ python "full path to ipython.exe"