Venv interpreter is faster than system interpreter?? Python 3.6 - python

I have been developing a Pacman game in python using pygame module, using IDE Pycharm. When setting up my project I went with the default settings in Pycharm and it set up a venv for me. Running the code from my system interpreter makes it run really really slow with the cpu usage being more than 200%, while running with the venv interpreter it works as expected and cpu usage is about 70-80%. My question is why is that and how to fix it.
I have not uploaded my code, because I thought maybe the problem is not with the code, however if you want I will edit the post and upload the code as well.

Related

Anaconda slows terminal

I recently installed anaconda to work with basic python scripts. The terminal started to be very slow on startup after installing anaconda: it loads the -python process and that's where it is really slow(about a couple of seconds but it's really annoying since the terminal was good to go instantly when i started it). I run on macbook m1. Is there any method to get rid of the loading of python at the terminal startup? And if not, is there any replacement of anaconda that is just as easy to use? I'm not an expert at python since i just started using it for a couple of months :)
I managed to get rid of the (base) environment in terminal but it seems that is not the cause of the slow startup

Python not found

I'm working on a project in a python virtual environment, the project was started on a pc with python 3.8 installed and consequently python 3.8 was used in the virtual environment, or I had the need to continue the project on another pc, so I loaded all on GitHub, in the end I downloaded it to another PC with python 3.11 installed, the files are all there but when I try, inside the virtual environment, to open python by writing python or python3 in the terminal, it shows up this error: Python not found; Run with no arguments to install from the Microsoft Store or disable the link from Settings > Manage apps Run aliases. I then tried to see if it only showed up inside the virtual environment, but the same thing happens outside as well.
I tried to do various things among those suggested in other forums but they didn't work, the problem persists, I'm a bit lost, it's the first time this has happened to me.
Sorry to bother, maybe it's the simplest problem there is to solve but I don't know where to start
Trhanks
The problem is the different version of python on the two computers... the content of the pyvenv.cfg file must simply be changed which, when creating the virtual environment, is based on the installed version. Here you just need to change the path to reach the python.exe file installed on your computer and then change its version by inserting the correct one.

Is it possible to run python scripts without python installed in Linux?

I once did something similar under windows, copying the whole python and specifying PYTHONPATH by a .bat script to make it work locally.
But today I got a Linux server that has a strict working environment and won't allow me to install anything. And unfortunately I know little about Linux. I wonder is there a similar way that I can run python on the server?
Yes, you can use python docker images for running python scripts.
I've built stand alone executables using pyinstaller. It works well. I've only used it to deliver into Linux so far.
Sorry, I cannot put a comment because of my low reputation.
In short, you cannot run a Python script directly without the interpreter installed. Fortunately, you can install a Python environment without root permission by using Miniconda (or Anaconda), then make a virtual environment and install the required packages to run your code locally for your use only.
This answer is to leave some reference for the subsequent people who encounter the similar situation.
If you choose to package via pyinstaller. Here is a good method. Almost no different from writing python. How to pack a python to exe while keeping .py source code editable?
NOTE: But there is some bad news, such as the glibc version issue. If you encounter this problem, you can refer to Pyinstaller GLIBC_2.15 not found

"No Tests were found" in Pycharm Professional 2019.1 using Behave

Starting Python BDD, using Behave in pycharm 2019.1 pro. Just started learning Python and Pycharm IDE.
Used a basic example to run a feature file with one scenario in it.
When I run using Pycharm Terminal, the scenario runs fine. When I do the same while right clicking on the Scenario in the editor, I get the message at run time, "No tests were found".
I have searched on SO but responses are for unit tests not for BDD tests.
I went into the run/debug configuration and have tried setup working directory to my feature folder or the project folder, but still the same issue.
I previously had python 3.7 but now using python 3.6 (both installed) and the interpreter is set to behave
I got it working but uninstalling pycharm, python 3.6 and python 3.7 folders completely (includuing hidden folders from private # root) from my machine, fresh install pycharm with python 3.6 and then behave. Tests work now.
No idea exactly why it happened except that it could be some conflicting config due to different python versions.

running python modules in python launcher

I made a small game of pong in python and the idle I used was eclipse and all of it works (for the most part). But when I try to run the game through the python launcher rather than eclipse it crashes immediately. In fact any program that I make in eclipse won't run outside of it. I'm basically trying to figure out how I will be able to put my game on other peoples computers.
What is the problem?
Your description is too generic, but I'll answer as to what is the most likely issue: your environment.
Fundamentally, eclipse does NOT use the pythonpath set in your environment. It has its own internal configuration (python interpreter, pythonpath, etc...).
So make sure your environment variables match your eclipse configuration. That is likely to solve your problem.

Categories