I'm newbie to pycharm so not sure if this is a common problem or not.
Whenever I debug a code with break points or run a code (for example unit tests code), pycharm is directly accessing the .egg version of my code which is usually different than the actual code version.
Is there a way to fix this problem?
Related
I installed a package via pycharm earlier. I made some changes to the package's source code but found that pycharm would still run the old version, and I discovered that pycharm was actually running the cpython compiled .so version instead generated from the old code. Is there a way to force pycharm to rerun cpython or just interpret the source code instead? I tried removing all the cpython .so files but that causes the pycharm to segfault, so I suppose some of those cpython files are actually needed.
Python: how to edit an installed package?
You really shouldn't be editing these packages directly, it can easily become a headache down the road. I would recommend following the advice in the above link if you really feel like you need to edit the package, because it keeps you from, well, breaking things.
As many others, I am running into the issue of PyCharm not using the newer version of a function in a different file when the function is imported into a .ipynb. The behaviour is as follows: I run the ipynb, importing the function. I change the function in a seperate .py file. I rerun the ipynb and the unchanged version of the function is still in use. I tried to fix this with the proposed fix found here: https://stackoverflow.com/a/60099037/5587736. However, this doesn't change anything. I need help running through this, because this fix seems to work for others.
everyone. I've been using python for a while with PyCharm, however I decided to go back on VsCode because I'm used to it.
I installed the python extension, specified the interpreter and compiled a basic file. Everything seems ok, except a strange path in the terminal which is annoying.
When I compile JavaScript it specifies the path rather simple:
C:\Program Files\nodejs\node.exe tests.js
However when I compile python it is a lot bigger:
PS D:\Projects\> ${env:DEBUGPY_LAUNCHER_PORT}='12345'; & 'C:\Users\user1\AppData\Local\Programs\Python
\Python38-32\python.exe' 'c:\Users\user1\.vscode\extensions\ms-python.python-2020.4.76186\pythonFiles
\lib\python\debugpy\no_wheels\debugpy\launcher' 'd:\Projects\app.py'
My question is, is this normal and is there a way to remove it or should I get comfortable with.
Two things. One, that's not compiling your code, it's running your code under the the debugger. Python doesn't really have a compiler step in the traditional sense.
Two, there isn't anything you can do about it. It's how the debugger launches.
I have a script that generates logs based on an equation. Initially I had no equation so it printed out “0”. I run the script through my IDE, the equation works. I compiled with PyInstaller, run it, it’s all the same, except the log is back to printing “0”.
Any idea what the cause could be?
I just spent quite some time struggling with the same problem, but found a solution. I know it's a bit late, but I'm leaving this for people who may find this useful in the future.
I have just found out that I had two versions of the folder containing my script: one of them was the one I was actively working with, and the other one was an outdated version whose existence I didn't even remember. Turns out PyInstaller was importing the outdated version instead of the one I was working with.
I figured this out by looking at the .toc files inside the build folder. I searched the 'Analysis-00.toc' file for my script, and found out that it was importing the wrong one. I deleted the wrong outdated script, cleaned all the pyinstaller files and created a new build. After that, it worked as it should.
I have a Python project in eclipse, which imports modules that can't be found by Python. Here's a list of some of the cases:
some of the files might import both the 2.x and 3.x versions of some built-in modules for compatibility purposes (but I can specify only one grammar version in the project's settings)
since the scripts I'm writing will be ran in an environment very different from mine, some of the modules I use don't even exist in the system (like Windows-specific modules, or modules from other projects that I REALLY don't want to link directly to this one)
modules that might or might not be installed on the machine where the script is going to be executed (of course, wrapped into try-except clauses)
and so on...
It is very annoying to have these modules marked as errors, since they make REAL syntax errors much less noticeable.
I know that this behavior can somehow be overridden - I have another project that doesn't mark unresolved imports as errors, but I just can't find the right setting for it. Can anyone help me?
How about adding ##UnresolvedImport to your imports? Eg:
import a_module_pydev_doesnt_know ##UnresolvedImport
You can simply press Ctrl-1 when your cursor is placed in a line where PyDev marked an error and and select the corresponding entry to automatically add it.
Edit: I don't have much experience with it, but it seems that if you want to change this for a whole project (or do it without touching your code), you can also add the module in question to the forced built-ins: http://pydev.org/manual_101_interpreter.html#PyDevInterpreterConfiguration-ForcedBuiltins