I am trying to install Sublime Text 2 on my linux machine and I cannot figure out how to run the python script to install it. I am fairly new to linux and never programmed in python before. I am trying to run the python script PackageSetup.py using ./PackageSetup.py but i get the error:
bash: ./PackageSetup.py: python: bad interpreter: No such file or directory
not sure what I have to do. I have python on my machine. I can tell cause running 'python' puts me in the console.
For all I know this kind of issue can occur if you have a misspelling or mistake in the shebang. I see two ways to solve this issue: you can try to invoke PackageSetup.py via python, like python PackageSetup.py or you can open PackageSetup.py and try to find an issue in the shebang, maybe it needs to be a full path to python interpreter like /usr/bin/python not just python.
BTW, why don't you try to install it via some kind of package manager - there is a repo for debian-based distros, and I'm pretty sure that there have to be repositories for other distributives.
Related
For test purposes,
I tried to install Blender as a Python module in a virtual environment with Python 3.7 to be sure that i can use bpy.
I follow this page for the installation (https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule)
I would like at the end, when I wrote a Python script who used blender command to be able to run outside Blender software and to get information when my script finish
So I have multiples questions:
I don't really understand this line of command for Windows and how I can adapt to my virtual environment :
xcopy /E bin\2.81 C:\Python37\2.81
I can't use 'import bpy' command even when I successfully do pip install bpy in the command line ?
For my final goal project, I'm afraid that it's impossible to do because I couldn't find examples or questions related to my project.
Can someone could explain a little if it's possible or interesting to use Blender externally ?
I am newbie with python and here is my problem. I installed python on my windows pc and as you can see on this picture, I checked it by the command python --version and it showed me the version, no problem.
But when I ran this very simple code:
my_text = "We made it!"
print(my_text)
It said to me that Python was not found! as you can see in the picture.
I searched on the internet, and add the path variable as they said in this guide:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
but it still does not run.
Could you please give me some advise on how to solve this?
Try using python to run your .py file, like this
python test.py
If you are seeing instructions that say to use python3 to run Python scripts, it's probably because the author of those instructions uses a system environment where python is used for Python 2 and python3 is used for Python 3.
In your case on Windows, Python 3 was almost certainly installed using python as the command to run, so you should use python and not python3 to run your scripts.
I have a program in a directory ~/trevor. Using Ubuntu, if I cd to this directory then I can execute this program with
$./program
However, I want to be able to execute this program from within a Python script, but when I try using
import subprocess.run
subprocess.run("./program")
I get the following error:
OSError: [WinError 193] %1 is not a valid Win32 application
How can I solve this?
I am running the python script through Pycharm's terminal. It has occurred to me that I could run the python script through Ubuntu's terminal, but then I have a problem with Ubuntu finding the correct packages. I am running Windows with a Ubuntu shell - I tried solving the Ubuntu package problem by changing Ubuntu's PYTHONPATH to the same path as Pycharm's project interpreter, but this didn't work either. I thought it would be easier to solve the problem above than to the package problem.
Thanks for the help.
As previously discussed in comments, and then included in an edit to the question:
The mistake was trying execute a Ubuntu program through a Windows command line. The solution here was to execute the Python script (with subprocess.run() or subprocess.call()) through the Ubuntu command line.
Insofar as executing Python on Ubuntu can't find Python packages/modules, this is because those packages/modules were installed through the Windows command line, so native/compiled dependencies they included were built for Windows rather than Ubuntu. Even if Ubuntu's PYTHONPATH is pointed to the location of the packages, there are some modules that won't work because they have platform-native components. The solution is to download the package again but through Ubunutu (such that they are suitable for a Linux distribution).
os.exec* typically works for both windows and linux as far as I'm aware, however it does require an a letter or two that replace the "*" in certain situations. You'll have to look at this to see which one you would need https://docs.python.org/2/library/os.html
ex. os.execl or os.execle
subprocess.call is an older version that will avoid a lot of the problems with shell specific conventions. If the issue is Ubuntu-nativity as the comment above suggests, this could fix it.
I'm trying to run a simple Python script every time I build my app in Xcode. The Python script is called test.py and resides in my project folder as a sibling to my .xcodeproj file.
I think I followed the instructions in the Stack Overflow post
Is this possible to run a python script before Xcode doing compiling? but I am receiving the error Shell Script Invocation Error: Command /bin/sh failed with exit code 1
I installed Python 3.5.2, but when I type python -V into Terminal I get Python 2.7.10. However, when I type python3 -V into Terminal I get Python 3.6.0. Typing which python into Terminal returns /usr/bin/python, while typing which python3 into Terminal returns /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.
Following the instructions in Xcode: Running a script before every build that modifies source code directly I also moved the Run Script section in Build Phases to before Compile Sources.
This is what my Run Script section looks like. I have a strong feeling that the fix is annoyingly simple but have been unsuccessful trying to figure out what I am doing wrong / what search terms to use in Google or Stack Overflow.
And of course, let me know what other info I can provide to help debug.
EDIT: I have no preference for which version of Python I use other than that it allows me to run a Python script each time I build. I just installed Python 3.5.2 because I thought it might help.
EDIT 2: Tried deleting Derived Data (even though I am using Xcode 8.2.1) in addition to Clean (Cmd-Shift-K) and Cleaning Build Folder... (Cmd-Shift-Alt-K) and still no luck.
I managed to get this working by using /bin/sh as my shell and python test.py as my script.
In the "Shell" input, try this path: '/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'
I'm new to Python and I'm trying to understand the basics things.
Before to install the python interpreter on my computer I downloaded Deluge (A torrent client written in Python) and it works without any issue, then I thought I must had Python running but if I run the command:
python --version
I get the error saying that python is not installed on my computer. How is it possible ? How is the code from Deluge executed ?
The software you've downloaded probably has python embedded in its distribution, hence it doesn't require you to install it separately.
Also, running python --version just tells you that python executable isn't in any directories on your PATH variable. It doesn't say it's not installed.
If I look at MacOS Deluge distribution, it has python bundled with it.
Generally, you need python interpreter to run any python programs.
That's probably because what you've download is an executable and does not require Python to be executed.