Tkinter no $DISPLAY or display name (Berkley pacman project) - python-2.7

I am trying to use Berkley's AI pacman projects.
Specifically this project.
A little bit about me: I'm on Windows 10 using cygwin as my terminal. I have both python and python3 installed as well as both versions of Tkinter and tkinter respectively. This project uses python 2.7. Trying to run the main project using the python pacman.py results in a long trace with the error being '_tkinter.TclError: no display name and no $DISPLAY environment variable'.
Calling echo $DISPLAY outputs an empty string.
I believe this is the most relevant file:
http://ai.berkeley.edu/projects/release/search/v1/001/docs/graphicsUtils.html
I understand this is a relatively specific and difficult issue, but any advice would be greatly appreciated. Thank you in advance!
Edit: I have installed xwin and the relevant packages. I am able to start a server in one terminal with startxwin and then I try to run the same command in another terminal but arrive at the same issue. I believe my problem is that I cannot establish the xwin server as my $DISPLAY.

Related

How to disable the GUI in order to run the C++ program via SSH?

I'm trying to run this program remotely via SSH, but since it has a GUI, I get the error: "Could not connect to any X display."
I don't need the GUI, since I made some adaptions and want to experiment with it. I'm very new to programming, especially in C++.
So far, I tried to solve the problem, by removing/commenting the lines related to the uvcvideoproducer in the main.cpp and compiling it again, but it's still looking for a display and doesn't start via SSH.
When I entered the command "export DISPLAY=:0" in the command line first, then trying to run the programm, I get the output: "No protocol specified
qt.qpa.screen: QXcbConnection: Could not connect to display :0
Could not connect to any X display."
I really don't know where to continue from here in order to solve the issue I'm having.
Thanks a lot, in advance for any help! It's very appreciated!
Thanks for your responses!
The thing about ssh -X is, my colleague said, it's sometimes not even working between different distributions, and I'm even using Windows to connect to Ubuntu Server on a Raspberry Pi. So sorry for not adding this important information into my original post.
I actually solved my problem by using the Xvfb library in order to simulate a display.
The only things I had to do are first installing it:
sudo apt-get install xvfb
And then run the program via the xvfb command:
xvfb-run -a --server-args='-screen 0, 160x120x16' ./GetThermal
I could also use a simulated display in the size of 1024x768x16 and probably many more formats, I just didn't notice any performance difference, when I was running it.

why im not able to import pygame? [duplicate]

I've downloaded pygame-1.9.1release.tar.gz from the Pygame website. I extracted and installed it and it's working fine in the command line Python interpreter in Terminal (Ubuntu). But I want to install it for some IDE, like PyCharm. How can I do it?
Well, you don't have to download it for PyCharm here. You probably know how it checks your code. Through the interpreter! You don't need to use complex command lines or anything like that. You need to is:
Download the appropriate interpreter with PyGame included
Open your PyCharm IDE (Make sure it is up to date)
Go to File
Press Settings (Or Ctrl + Alt + S)
Double click on the option that looks like Project: Name_of_Project
Click on Project Interpreter
Choose the interpreter you want to use that includes PyGame as a module
Save your options
And you are ready to go! Here is an alternate (I have never done this, please try to test it)
Add PyGame in the same folder as your PyCharm file (Your PyCharm stuff is always in
a specific file placed by you during installation/upgrade)
Please consider putting your PyCharm stuff inside a folder for easy access.
I hope this helps you!
For PyCharm 2017 do the following:
File - Settings
Double click on your project name
Select Project Interpreter
Click on green + button on the right side of the window
Type Pygame in search window
Click Install package.
Not I'm saying that the answers above won't work, but it might be frustrating to a newbie to do command line magic.
If you are using PyCharm and you are on a Windows 10 machine use the following instructions:
Click on the Windows start menu and type cmd and click on the Command Prompt icon.
Use the command pushd to navigate to your PyCharm project which should be located in your user folder on the C:\ drive. Example: C:\Users\username\PycharmProjects\project name\venv\Scripts.
(If you are unsure go to the settings within PyCharm and navigate to the Python Interpreter settings. This should show you the file path for the interpreter that your project is using. Credit to Anthony Pham for instructions to navigate to interpreter settings.)
HINT: Use copy and paste in the command prompt to paste in the file path.
Use the command pip install pygame and the pip program will handle the rest for you.
Restart you Pycharm and you should now be able to import pygame
Hope this helps. I had a fun time trying to find out the correct way to get it installed, so hopefully this helps someone out in the future.
I just figured it out!
Put the .whl file in C:\Program Files\Anaconda3
While in the folder, click on the blue File tab in the upper left corner of the Window Explorer (assuming you're using Windows)
Click on Open Windows PowerShell as administrator
Write or just copy and paste: py -m pip install pygame
It should start installing
Done!
I hope it works for you. I know it did for me.
I already had pygame installed with python38-32
since its working just fine with it. I used this version of python us my project interpreter.
1.File -settings
2.according to your settings look for project interpreter
3.click on your current project interpreter and click on the add symbol
4.choose system interpreter
5.select the python version thats works with pygame for you
6.Note: some versions of pygame don't work with some versions of python be sure
of what are you doing.
7.hope it works.

nfcpy python 2.7 pyinstaller

I am working on project that reads near field communication card and identifies the card user, I am using nfcpy with python 2.7, my nfc card reader is acr122 by ACS and I am working on windows 10. The application seems to be working fine when I run the python script. However, when I convert the python script to .exe using pyinstaller I have error "no module named acr122". Is there any specific protocol I have to follow to bundle nfcpy in exe file. Any help would be much appreciated, Thank you in advance.
finally, found a solution, I need to import ['nfc.clf.acr122'] as hidden-input.

Python IDLE giving startup error

I have just installed kivy in python 2.7.11. After installing it, whenever i try to open IDLE, it is giving subprocess startup error.
Actually i installed kivy on my windows 7 PC through command prompt. After installation, I copied programs of kivy from my android tab to run them on my pc. When I tried to open them, IDLE doesn't respond for some time and after some time it gives startup error. Since then IDLE is not starting .
But it is quite strange that, on running python builtin module, there is no error.
I had reinstalled python but still there is no change.
reason for subprocess startup error can be a new python file that you have created recently with the same name as same existing libraries or module name
e.g. 're.py','os.py' etc
beacuse re,os are the predefined libraries
just go and find the file and rename it
hope so it will be resolved

Calling a OSX package from xcode c++ program terminal

im planning to build a c++ application based on another c++ package (aria2c) i found over the internet which acts as a ready made wheel for me. I have already installed the package on my machine, but the problem is when i run system("aria2c"); it outputs "command not found", whereas if i run system("git"); (which i have also installed) it will output the git's man page.
calling "brew" also doesnt work whereas git, ls and some other that i tried work.
So can someone explain to me why i cant access that package ? and if there is any solution to it ?
The most common mistake is that the pacakge might be installed for a particular user or at a particular path. Make sure that you have the library/application in your path list
To do that ,i would suggest first finding where the package is installed and then do echo $PATH in terminal to see if its in your path variable