I am attempting to create an application for changing the wallpaper with gnome-builder. I've chosen to create this application in Python, and figured that I could do this using subprocess.Popen(["hsetroot", ...]) however every time I try this I get the following error:FileNotFoundError: [Errno 2] No such file or directory: 'hsetroot'.
This confused me because I know that hsetroot is installed and running the same command from the terminal works. I decided to do some investigating, and listed the contents of /usr/bin from the terminal using ls /usr/bin. Among the list I found hsetroot. I did the same thing in the Python script with subprocess.Popen(["ls", "/usr/bin"]) and upon checking the list of programs, hsetroot was not there.
Why is hsetroot seemingly gone when I try running it from a Python script with subprocess.Popen() and how do I fix this? I apologize if it is obvious, I have been searching for the answer for over a day now and I am completely stumped.
On Debian GNU/Linux 11, I am running the application using GNOME Builder's built-in run button. GNOME Builder was installed via apt-get install gnome-builder. From there I created a new python project using the "GNOME Application" template. In the project I am attempting to use subprocess.Popen() from src/window.py.
Related
I have just started working on my new pc and just to get a feel for it I wanted first to start working on python files, so I started first by just wanting to run WSL on windows and it installed correctly but when I want to run any python using the run python file on the top right on VS code, this is what gets executed $ C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe f:/Projects/hello.py
And this is the error: -bash: C:/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe: No such file or directory
I have no idea what's causing it but when I run the file using 'Shift + Enter' which is: Python: Run Selection/Line in Python Terminal it seems to run the single line correctly but it gives me this error instead:
print("Hello, world")
-bash: syntax error near unexpected token `"Hello, world"'
but when I run it using python3 hello.py, it works perfectly fine?! I'm so lost as to why this is happening and how could I fix it.
Might be relevant: I'm using windows 10, installed python 3.10.2 from windows store, all of that is in VS code and the python code is one line: print("Hello, world") and I changed the permissions of Local/Microsoft/WindowsApps so it's now accessible by all users to view/read/edit/run, made sure that python3.10.exe exists(on the WindowsApps and it works perfectly) and reinstalled it many times, tired python3.9, and tried to install python from the website instead of the windows store and still the same, manually added python to PATH and tried .venv and didn't work. when I launch python3.10.exe outside vs code it seems to run perfectly, I have worked with python before and it used to work fine now I don't know what's wrong.
I have seen other questions of the same problem I'm having here but none of them solve the problem.
No such file or directory C:/Users/...
For wsl, the Windows filesystem is accessible, but it has a different path. It is mounted under the /mnt folder. So you would find your python .exe under /mnt/c/Users/jaffe/AppData/Local/Microsoft/WindowsApps/python3.10.exe. This said, the executable file is meant to work on Windows, and it doesn't really makes sense to use it on Linux when you could run python within your wsl distro.
python3 works perfectly fine
This is because most Linux distributions come with python3 pre-installed, so you can use it already. To see where it is located, you can run the command which python3, or python3 --version to check its version.
If you want to change version, you may consider download it from you package manager, apt.
I also suggest to install python3-pip if you don't have it already to get the pip package manager for python.
In my case when I ran into this.. I discovered pyenv. This allows you to download more than one version of python. You can then go into a specific directory, such as your python project and issue a python local 3.10.0 (for example). Here's a link on how to install it as well as poetry which is a virtual environment manager that is become very popular. You can also create an alias for python that works off of this. I add this command to my alias file and source it from my .bashrc. alias python='pyenv exec python3'
I've gotten this to work relatively easy on my Mac I with django but for some reason Windows has been a heartache.
the problem is that in the console I can only get py to start executing python.
python and python3 do not work whatsoever
and also I can't get pip to install either because the py command won't execute it but python and python3 just open the windows store.
I've installed python to the path with the installer and I made the location of the file C:\Python\Python39
changed the hierarchy in the PATH in user variables and system variables to where python is at the top in both.
I've edited the vscode settings
I've also turned off the App execution aliases. That did nothing.
I'm at a complete loss so if any one has any advice I'd be so appreciative.
This tutorial helped me make pip working when I started programing
https://youtu.be/28eLP22SMTA
This is my first post so be gentle! I'm also in the process of learning python independently (trying to make engineering-related webapps using flask).
I have set up a project using virtualenv, and I've used the virtualenv-associated pip (what do I call this?) to install control.
Now, when trying to play around with the control package to play around with it, I am running an instance of the virtualenv's python3 interpreter (I've tried doing this by using the python3 command with the virtualenv activated, and by executing the project's proj/bin/python3 command) and I import control.
Oddly, this opens another python interpreter running on my desktop. Here's the
icon that appears on the mac doc.
Why is this second interpreter opening upon importing the control module?
Thanks for any help!
I seem to have problem launching python from command line. I tried various things with no success.
Problem: When trying to run python from the command line, there is no response i.e. I do not get message about 'command not found' and console does not launch. Only option to open python console is to run C:\Python34\python.exe directly. Running using python command does not work even when in the python directory but python.exe launches. Issue with the launching this way is that python console is launched in new window. This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed.
PATH is correctly set to
C:\Python34\;C:\Python34\Scripts;...
and where python correctly returns C:\Python34\python.exe. I verified that running other commands imported through PATH (such as javac) run correctly.
Things I tried:
Completely re-installing python both with x86 and x64 python installations with no success.
Copy installation from my second machine and manually set the path variables - again no success.
Can anyone hint how to resolve this behavior?
(Additional info: Win 8.1 x64, python 3.4.2)
Issue resolved. Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. This resolved the issue after re-installing python.
If anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference.
Recent Python installer has option to add PATH.
If you didn't use it, you can register directory where python.exe is to PATH environment variable.
But I prefer py launcher. It may be installed via Python 3.3 or 3.4.
With it, you can start Python via py or py -3.4.
See https://docs.python.org/3/using/windows.html#python-launcher-for-windows
I have a program that I'm trying to distribute with py2app. When I run the program from the command line, it works without any problems. It also works if I go into the package that py2app creates and find the exec inside the package contents and run it from there. There are not any errors in the output during the build process.
However, when I double click the app in the dist folder, I get an error that says MyApplication Error and has a button to terminate and one to go to the Mac Python website.
I'm using py2app with Python2.7 on Snow Leopard. I'm not using the system Python, this is a distribution I installed myself.
How can I trouble shoot this?
Check the Console (Applications > Utilities). All stack traces from py2app applications get printed there.
I had this problem today, and my solution was that there was something broken with argv_emulation in py2app itself, so I had to set it to False in the OPTIONS dict. It's set to True by default.