How to setup springpython with Jython and Eclipse/PyDev? - python

I'm having trouble setting up SpringPython with PyDev and Jython
I've installed Spring python by:
jython setup.py install
and the setup installed the library to my jython installation successfully.
See!:
In my PyDev project i've selected the jython interpreter and have c:\jython2.5.1\Lib\site-packages in my Library paths:
My eclipse environment fails to resolve the new classes:
What else do I need to do to install this baby?
Perhaps I should just be using the Java version of spring...
Thanks SO!

The python interpreter that is used to compile your Python files is specified by PyDev on the project level. I suspect that while you do have Jython installed, your Eclipse project (katas) still uses CPython.
Perform the following steps to fix this:
Open your project properties: right-click your project folder ("katas") and select properties
Select tab "PyDev - Interpreter/Grammar"
Switch Python to "Jython"
Your files should now be compiled correctly using Jython.
As noted by the asker himself, you may need to restart your editor (or the Eclipse itself).

Turns out that I just needed to restart eclipse, there you go.

Related

Why Virtual Studio Code can't find my virtual environments instaled modules?

Always when I create a new Python project file, in Visual Studio Code, and I import some modules, it marks the ones VSC can't find, but they are already installed in virtual environments.
How can I fix this bug? Thanks!
Select and activate an environment
By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. If it doesn't find an interpreter, it issues a warning. On macOS, the extension also issues a warning if you're using the OS-installed Python interpreter, because you typically want to use an interpreter you install directly. In either case, you can disable these warnings by setting python.disableInstallationCheck to true in your user settings.
Check this link: https://code.visualstudio.com/docs/python/environments

Why won't PyCharm see my libraries?

If I do something like "import selenium" (or any other kind of third party library) in a .py file and then run it from the terminal, it works just fine. But if I make a new file in PyCharm CE and do the same thing, it can't find the library / module.
How can I fix this or get it to point in the right location? I use a Macbook Pro.
You need to setup your project in PyCharm to use the Python interpreter that has your libraries:
Go to: file->settings->project->project interpreter
And select the appropriate interpreter from the dropdown. After selecting an interpreter, the window displays a list of libraries installed on that interpreter; this should further help you make the right selection.
I've faced a similar issue on Pop!_OS after installing PyCharm via Flatpak. I think the installation is somehow incomplete, as I've had these issues (among others):
Installer could not create the menu shortcut due to the lack of credentials. Unlike during a typical installation, it wouldn't ask for the password and instead I had to uncheck that option altogether.
Built-in terminal defaulted to sh. Even after changing to bash, it would not read my .bashrc and many commands were missing.
After changing the interpreter into a local virtualenv, it would just default to Python 3.7 (even though the version was actually 3.8) and it didn't see any of my installed libraries.
When I've tried to use a Docker Compose environment, IDE failed to detect Docker Compose installation.
I've eventually uninstalled PyCharm and downloaded it directly from Jetbrains website to make it work correctly.

Making my IDE take a specific Python version

I have Python 2.7.8 installed and when doing the version check in my command line, it shows that I have Python 2.7.8.
However, when I run PyCharm it's running it on version 2.6. Is there a way for me to get it to make PyCharm take the 2.7.8 version?
Thanks for the help!
By default, PyCharm picks up the Python installed system-wide.
Which Python your project should use is configured under Project Interpreter section of your Project Settings. From there, you can add existing interpreters either locals, or remotes, even create brand-new virtual environments and manage packages inside.

Changing PyScripter to work with different Python Versions

I'm using PyScripter for writing python programs and I can't figure out how to make it work with Python26 on my computer. When I installed ArcGIS, by default it installs Python26. I then installed PyScripter which found that installation and it worked fine. Later, I installed Python27, and subsequently reinstalled PyScripter.Now Pyscripter uses Python27 and I don't know how to change it.
I've looked at the settings under Tools -> PythonPath and they are as follows:
and also Tools -> Configure Tools
I assume I need to change the python path entries, but what do I change them to? My Python26 installation is found in C:\Program Files (x86)\ArcGIS\Desktop10.0\Bin.
If you go to the pyScripter folder in the start menu, it will have a version of pyScripter for Python 2.4 to 3.2. Just run the one corresponding to your Python version.
go to the pyscripter shortcut : right click then select Properties,
add the option to the target : --PYTHONXX
wherein XX the Python version.
ex : "C:\Program Files\PyScripter\PyScripter.exe" --PYTHON24
Copy/paste another shortcut and modify the option to another python version.
Easiest way to change the python version in PyScripter is:
Run->Python Version-> Setup Python Versions->Add New Python Version->
Browse to your python exe and select ok.-> Click on Activate Selected Python Version..
Now restart your PyScriptor and your are good to go.

IDE don't see all the functions

i'm using Elcipse+PyDev and Pyscripter sometimes for Python 2.7
Yesterday i installed PyTables from compiled binaries and :
import tables
h5f = tables.openFile(r'D:\sample.h5','w')
h5f.createGroup('/','Box')
h5f.
So, when I type "h5f." IDE don't show me all the methods, only a few!
Can't do anything with It, installed PyTables few times,same result...
Method h5f.CreateGroup() works perfectly, but IDE dont see it so don't display it in drop-down list! Eclipse and Python both behave same...
The thing with Pydev and Eclipse is that when you install a new package or library and if you want to use the auto-complete with it, you will have to recreate the system PYTHONPATH in eclipse.
For that go to: Window -> Preferences -> Pydev -> Interpreted Python and in the tab libraries, in System PYTHONPATH you will not see your new installed library because pydev just do a copy of the PYTHONPATH the first time that you have configured and now each time you installed a new package you will have to resynchronize pydev with the new PYTHONPATH.
So to resynchronize you will have to click on the button Apply so that eclipse export (again) all the library (between them your new installed one) from PYTHONPATH to eclipse.
So now eclipse should know your library and you should work with it just fine.
Hope this will help :)

Categories