For the last 2 days PyCharm won't create the configuration setting to run my Python files and I have to create them manually to run my codes.
Before that PyCharm created those configuration setting for me, and all I had to do was just press Shift+F10.
Any ideas?
If you're using Linux or Mac, I've seen a similar (not the same) issue where the app (in this case PyCharm) was installed with root user via sudo and then the executed as normal user, that then won't have permissions to create/change the configuration files, which in PyCharm's case is the .idea folder in your project folder.
If this was previously working, maybe an update to PyCharm while you were running as root may cause the same issue (folder root becomes the owner of the folder and normal user can't change it).
Related
I keep running into path issues in my flask app, when running in PyCharm. I've set the working directory in my run configuration to project-root/api/src, but the relative paths to resources don't resolve properly.
To check what's going on I ran os.getcwd() and I'm getting project-root.
What am I doing wrong? I tested the same project with a colleague with a identical (to my knowledge) configuration and on his machine os.getcwd() properly returns what is expected, project-root/api/src.
I tried reconfiguring the project from scratch, by removing .idea folder and creating the project again in PyCharm, to no avail.
I'm using macOs BigSur, Python 3.9 and PyCharm 2021.2.1.
Screenshot below contains my configuration (sensitive info, like company/project name removed):
I managed to solve this issue myself - the reason was that I'm using pipenv, which requires a .env file to be present in the root of the project folder. Flask, when finding such a file, switches the working directory to the root project folder, disregarding any PyCharm setting.
A solution to this is to add a FLASK_SKIP_DOTENV=1 to the application environment variables.
Described in detail here: https://github.com/pallets/flask/issues/3209
I have a shared flask web project I am working on with 2 other developers, one of the developers initialized the venv on his pc, uploaded his project structure to github from where I cloned his repo.
Now I when I start vscode and open the project folder, python does not auto detect the venv and asks if it should set is as the interpreter, the only option I have is the default system wide python install, and not the venv python interpreter.
I tried adding it to the list by using the command python:select interpreter and then finding the python.exe inside the venv/scripts folder, but this does not work and vscode still asks for a interpreter.
I also tried manually adding it inside of my workspace settings.json file like so
"python.pythonPath": "C:\\laragon\\www\\Proftaak\\venv\\Scripts\\python.exe"/
But vscode also gives an error on this saying the interpreter is not valid.
How would I fix this?
This is not expected to work as virtual environments are not designed or meant to be movable. They are meant to be created on each machine you need a virtual environment on. As such, I suspect that the virtual environment does not work outside of VS Code which could prevent it from selecting it as a possible working environment.
Where is the odoo class and module defined? What should the pythonpath be?
I'm having problems setting up ODOO 10 community to run from Eclipse on Windows (10). This boils down to two problems: I can't find where the odoo class is defined so cannot import the odoo module, and I don't know what the PYTHONPATH should be.
Details:
My main module in the Eclipse debug configuration is set to oddomain.py (renamed from odoo, in the setup folder) with the code:
# set server timezone in UTC before time module imported
# Israel time zone is IST so I'm hoping this will work
__import__('os').environ['TZ'] = 'IST'
__import__('pkg_resources').declare_namespace('odoo.addons')
if __name__ == "__main__":
odoo.cli.main()
I get: missing odoo module from path
I set up ODOO 10 community in eclipse on windows 10. I learned how to do it from comparing these posts:
Installing ODOO 10 Source,
How to debug ODOO in Eclipse in Debian
and this old ​post: How to debug ODOO in Eclipse under windows
I'm running on MS Windows 10.
I have eclipse with Pydev installed.
I have the recommended python version (2.7.9) installed
I have the Postgres set up ok. (with BigSQL)
I have forked the odoo project on github and have the clone from github, locally.
I have the project set with the pydev nature.
I have all the packages installed by editing requirements.txt and running pip install -r requirements.txt in a cmd window in the odoo project directory.
I set up the odoo.conf with passwords for the postgres admin and odoo correctly.
I renamed the setup/odoo file to setup/odoomain.py and after reopening it in eclipse, it is recognized as python and I can set breakpoints. (calling it odoo.py was causing a problem, so I called it odoomain.py)
I set up the debug configuration of pydev to run the setup/odoomain.py as the main.
But I can't find the where the odoo class is defined, and therefore can't import the odoo module! Where is it defined?
What should the PYTHONPATH for the project be? I set it in Eclipse:Project/Options)...
It is now set to
/$/PROJECT_DIR_Name)/odoo/addons
Where is the odoo module defined, and how do I import it? Is it something to do with the PYTHONPATH?
OK the problem was twosome.
First of all I had to correct the pythonpath to include the root, and to include the odoo path. So now I have the PYTHONPATH set to 3 places.
/$/PROJECT_DIR_Name)/odoo
/$/PROJECT_DIR_Name)
/$/PROJECT_DIR_Name)/odoo/addons
In order to determine the correct path, you have to do "import odoo" in a python window from different paths (by changing directory in COMMAND window and running python again) and until it works, and set that
To set the pythonpath in eclipse:
Right-click on the project:
PyDev
Set as Pydev Project
Right-click on the project
Properties
PyDev - PYTHONPATH
Source Folders tab
Add source folder
It works only if I add the root as the SECOND path, and only if all three are there.
Then I had to correct my debug configuration (by editing the "variable") as follows: CORRECT
`--config=C:\MyPath\MyOdooProject\debian\odoo.conf`
Instead I had used the Browse and added the --config to get: WRONG
`--config=C:\MyPath\MyOdooProject\debian\`
And finally I had to run the Postgres on windows and connect to it in the PgAdmin. (I configured it already as requested and had the credentials listed in my debian/odoo.conf as explained.)
Everything runs ok now!! Thanks to Pham Tung for showing me the light!!
When I create a new remote Python interpreter, IntelliJ doesn't find any dependencies to my code and doesn't seem to index any libraries. Most of the code is red. I think I've pinpointed that to the "classpath" being completely empty, which is unlike some other Python SDKs that I have added (local ones). Some of the times I am able to get it to populate the classpath with paths pointing to the IntelliJ Caches directory by clicking around in the interface, but I most of the times it does not work and I cannot reproduce how to make it work. How do I make sure the classpath gets populated correctly?
I am using IntelliJ Ultimate version 2016.2.1. with the Python plugin version 2016.2.162.43. I am developing on a Vagrant virtual machine and I'm adding a Python remote interpreter that is inside a virtual environment (venv) inside the virtual machine. When I add the remote interpreter, I use:
On the SDKs tab - the + button.
Python SDK
Add Remote
I select the Vagrant option
Point it to my Vagrant project directory.
Point it to the python3.5 executable inside my virtualenv
Add the SDK
Then the classpath looks like this: https://www.dropbox.com/s/3xbzopb4y9bhn0u/Screenshot%202016-08-11%2017.19.43.png?dl=0 and IntelliJ doesn't recognize any libraries/builtins. For other SDKs, the classpath contains several entries with remote_sources, python_stubs or python-skeletons in the name and they work.
As a workaround, I copied every entry from the local python interpreter classpath to the remote one and everything seems to work
Edit:
Actually, I don't know what triggered it, but some days after I wrote this, I noticed that IDEA started downloading source files from the server. I went to the interpreter settings, and the classpath entries I had manually added were gone and replaced by "system/remote_resources" entries. I think this is how it's supposed to work, but unfortunately I don't why I didn't work from the start nor how to trigger the correct behavior, it just started working on its own.
While this issue is a bit older, I had the same issue today with IntelliJ IDEA 2021.2.
I was able to solve this by using Navigate -> Search Everywhere -> Type interpreter -> Select Rescan Available Python Modules and Packages.
This prompted downloading of the remote resources and indexing. Afterwards, the classpaths were filled in properly.
I am having an issue with implementing git hooks with the Github Desktop client for windows. When I created the hook, it runs a python script that checks the commit message. The weird part is, it runs on perfectly fine on Windows with command prompt, powershell, tortoisegit, webstorm IDE, git bash, also works on Linux terminal, EXCEPT for Github Windows client. reading the debug log, i get this error
GitHub.IO.ProcessException: /usr/bin/env: python: No such file or directory
My already attempted solutions:
adding 'python' as system variable
using ruby
removing '/usr/bin/env' (this will throw an error saying this file doesn't exists)
adding a .bashrc file solution i found online by putting the python path in my home directory
Does anyone have any idea how to fix this?
This error means that Git cannot find
To fix that, append C:\Python (or wherever you installed python) to your PATH environment variable in windows (control panel > System).
Once you set it up test the hook again.
Another option is to create a .bashrc file in your %USERPROFILE% directory and set the variable there:
export PATH=/c/Python:$PATH
Again - check to see that it fixed the problem.