I am trying to use sublime to write code, I want to know how to configure sublime so it can do auto-complete as eclipse does?
I have installed PyQt4, and it's ok if I use eclipse,
if I write the following code:
from PyQt4. After I input the dot, a list of possible matches will show in a drop-down list?
how can I do this with sublimerope?
I am using mac. Which configuration needs changed?
The solution here
http://messymind.net/2012/07/why-you-should-use-sublime-text-2/
worked for me:
Go to your new .ropeproject folder in your project and edit the config.py. Find the section that looks like this:
?
#You can extend python path for looking up modules
#prefs.add('python_path', '~/python/')
Here you can add the sources to your site-packages and your current open project, e.g.:
?
prefs.add('python_path', '/path/to/site-packages')
prefs.add('python_path', '/path/to/your/project')
Related
I'm trying to follow the tutorial on jetbrains (link: https://www.jetbrains.com/help/pycharm/pytest.html) about using pytest in pycharm so I can work on test driven development. I'm stuck at the part where I'm supposed to create a test for a specific function in the Car.py module (found here: https://www.jetbrains.com/help/pycharm/creating-and-running-your-first-python-project.html#) by hitting ctrl+shift+T and then clicking "Create new test...".
Screenshot of the step in the tutorial I'm stuck at.
When I click "Create new test..." nothing happens. The dialog box which is supposed to pop-up does not appear.
I've gone to Settings>Tools>Python Integrated Tools and changed Default test runner to pytest like I'm supposed to. I checked packages in the Project Interpreter and pytest version 5.3.5 is there which I just installed. I restarted pycharm for good measure. Does anyone know why the dialog box might not be appearing? I'm sure there is a more manual approach to making the test file but the built-in pycharm ability to do this quicker/easier is preferable.
Thanks for answering your own question, you have given me an idea for my solution.
For what reason so ever, I was not providing PyCharm a root directory for my project so it was not recognising my files.
I changed it under:
Preferences > Project:"your project name" > Project Structure
It was a silly mistake in my case. I was not opening the proper project folder. Instead I was opening parent folder.
My hierarchy was
E:\Projects\SampleProject
Instead of opening SampleProject in PyCharm, I was opening Projects directory whole.
I think PyCharm will only open this if it recognizes valid structure of the project.
Press Ctrl+Alt+S to open the Settings window, go to Project <project name> > Project Structure and mark your source folders as Sources (highlighted as blue in my version of PyCharm). Then you should be able to create tests for them.
I want to write IDAPython scripts and plugins. The problem is to get my Python IDE (PyCharm) to resolve the imports correctly and therefore get code completion correct.
Here is an example. I want that code completion works for IDAPython commands like:
ea = ScreenEA()
or
ea = idc.get_screen_ea()
Here is what I did. I downloaded IDAPython and put the source in my Python projects source folder.
I also copied the python folder from the IDA install directory into my Python projects source directory.
It turns out, that Pycharm cannot resolve the functions correctly.
How to setup Python IDE make auto complete work?
As long as the IDAPython files show up in you Pycharm project, or are in the same folder, you simply need to import the file you want to use.
So for your idc.get_screen_ea() example, as long as you have this at the top of your python file you are working on:
#import idc
Then you will get suggestions for anything involving idc.
Here is the method I took for PyCharm Windows version. First create an venv based project with the python version match your IDA python version.
File -> Settings -> Project -> Python Interpreter
Click setting icon, select Show All...
Select the interpreter you currently use, click Show paths for the selected interpreter
At the popup window, add your %IDA_INSTALL_PATH%\python
Then you can use PyCharm IDE features to write IDA python plugin.
I am beginning to look at python, so when I found a tutorial it said that the first thing to do would be to download python from www.python.org/downloads/
Now when I downloaded python 3, I then started the installation and got to
Why would I want to "Add Python 3.5 to PATH"? What is PATH? Why is it not ticked by default?
PATH is an environment variable in Windows. It basically tells the commandline what folders to look in when attempting to find a file. If you didn't add Python to PATH then you would call it from the commandline like this:
C:/Python27/Python some_python_script.py
Whereas if you add it to PATH, you can do this:
python some_python_script.py
Which is shorter and neater. It works because the command line will look through all the PATH folders for python and find it in the folder that the Python installer has added there.
The reason it's unticked by default is partly because if you're installing multiple versions of Python, you probably want to be able to control which one your commandline will open by default, which is harder to do if both versions are being added to your PATH.
In addition to what #SuperBiasedMan stated, you can edit your PATH in Windows by hitting Start > Run, then type sysdm.cpl.
From there, navigate to Advanced tab and then hit Environment Variables.
In the lower section, where it says 'System variables', find the one named PATH and double click it. Note that it would be easier to copy and paste it to a notepad or something. The separator as you can see is a semi-colon.
Any path that you add to this variable, will be looked when you type any command in a cmd window or through the 'Run' command line.
That's the same concept as in Linux, I just pointed out how it can be edited.
This shows the way if you haven't add python to PATH(By the way, the python.exe is in my Python directory)
This is the way if you add python to a PATH
Does auto-completion for the Panda3d library working with PyCharm? It seems PyCharm cannot automatically create the Python skeletons for this library. I would also be happy if I could at least manually define those stubs in PyCharm.
Any ideas how to tell PyCharm what Python modules and classes are there in a "binary" library?
For me it worked just selecting in Settings > Project Interpreter the panda python interpreter (python.exe, not ppython.exe.).
If you wanna use ppython.exe you have to rename to something starting with "python" like pythonpanda.exe, since Pycharm only considers an interpreter something that starts with "python". Anyway, ppython and python are supposed to be the same.
EDIT
Another thing that can make it work, is using another python interpreter (the standard, virtualenv, whatever) and placing a path file in a folder within the PYTHONPATH.
In other words:
Create a text file named panda3d.pth
Write two lines
path\to\pandafolder
path\to\pandafolder\bin
Save it in the site-packages of your python interpreter
Configure Pycharm to use this interpreter
I need major help getting started! I managed to create a new project, and add python.exe as the interpreter. But when the project is created it's blank. How do I start programming? Ugh.
Create PyDev project
Add "Source Folder" under the project
Add "Modules" to the "Source Folder"
Get coding :-)
Open a new text file and start writing code?
You need to make sure you create a Pydev project. If you don't already have a Python interpreter installed, you'll need to get one (this is mainly a problem on Windows, ActiveState is a great commercial grade distribution, python.org also has some great free builds of Python.) Once this is complete, you'll need to get into your global Pydev preferences (not the preferences for your specific project, but for all Pydev projects) and select the interpreter of your choice. Pydev will automatically scan the libraries included with your interpreter distribution and make them available for code completion. Then, you'll need to create a source file in the 'src' folder that contains code. Run it by choosing a run configuration that matches up with your interpreter choice (regular old Python in your case, not Iron python or Jpython). Most entry point python modules will have a main function like in C/C++ that looks like this: What does if __name__ == "__main__": do?