Using PyCharm as editor

Need help, or want to share a macro? Post here!
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Using PyCharm as editor

Postby more11 » Tue Mar 29, 2016 9:18 pm

I want to use PyCharm as an editor.

How do I get rid of the errors? I cannot figure out how to add FreeCAD as an exernal library in PyCharm.

Any help appreciated.

Mårten

PyCharm is:
PyCharm Community Edition 5.0.4
Build #PC-143.1919, built on January 28, 2016
JRE: 1.8.0_51-b16 x86
JVM: Java HotSpot(TM) Server VM by Oracle Corporation

FreeCAD is:
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6634 (Git)
Build type: Release
Branch: master
Hash: 297e84e3f064356d2a3403345e83a454a7eea923
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
Point taken :-)
wmayer
Site Admin
Posts: 17305
Joined: Thu Feb 19, 2009 10:32 am

Re: Using PyCharm as editor

Postby wmayer » Wed Mar 30, 2016 7:57 pm

I have downloaded PyCharm and when running it the very first time you have to define the path to the Python interpreter. If you define the path to the python.exe of the FreeCAD installation then using the FreeCAD module seems to work fine.
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Using PyCharm as editor

Postby more11 » Wed Apr 06, 2016 9:22 pm

I installed the FreeCAD python as project interpreter. Still got plenty of errors.
Point taken :-)
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Using PyCharm as editor

Postby more11 » Thu Jul 21, 2016 10:08 pm

Now I have an ubuntu based setup. I still cannot figure out how to edit python files in PyCharm. I have added /usr/lib/freecad/Mod as a Content Root.


OS: Ubuntu 16.04 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.15.4671 (Git)
Branch: releases/FreeCAD-0-15
Hash: 244b3aef360841646cbfe80a1b225c8b39c8380c
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

PyCharm Community Edition 2016.2
Build #PC-162.1237.1, built on July 20, 2016
JRE: 1.8.0_76-release-b216 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Point taken :-)
User avatar
salp
Posts: 240
Joined: Thu Nov 21, 2013 11:58 pm
Location: Putnam, NY

Re: Using PyCharm as editor

Postby salp » Mon Aug 01, 2016 1:09 am

I haven’t used PyCharm Community in a while, but this is how I configured my project settings to be able to import the FreeCAD modules.

Open your PyCharm project then select File -> Settings
PyCharm_1.png
PyCharm_1.png (143.45 KiB) Viewed 5308 times
In the settings dialog, expand the Project:<name of project> and select "Project Structure"
In the far right column select "+ Add Content Root" and navigate the folder you want.
On my system the folder is "/usr/lib/freecad-daily/lib", yours may be different.
PyCharm_2.png
PyCharm_2.png (65.62 KiB) Viewed 5308 times
Hope this helps.
Sal


OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8054 (Git)
Build type: None
Branch: master
Hash: 8fe7c94452e4a5f083162e6ff004d3575878c546
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Using PyCharm as editor

Postby more11 » Mon Aug 01, 2016 6:57 am

Thanks Sal

This is exactly what I have done. But I still get "No module named Part" and "Unresolved reference FreeCAD".

I have tried

Code: Select all

/usr/lib/freecad-daily
/usr/lib/freecad-daily/lib
/usr/lib/freecad-daily/bin
/usr/lib/freecad-daily/Mod
Point taken :-)
User avatar
salp
Posts: 240
Joined: Thu Nov 21, 2013 11:58 pm
Location: Putnam, NY

Re: Using PyCharm as editor

Postby salp » Mon Aug 01, 2016 11:52 pm

Marten,

Are you trying to run the code inside PyCharm?
I only ask because I have run into issues were the code is not executed consistently.
For example the code in the screen shot runs in debug mode, but if I create a new file it cant even find the FreeCAD source.

Have you looked Eclipse with the PyDev add in? I'm going to give it a shot and see if its any easier to configure.

Please keep us up to date, I think many people would like to see how to utilize an IDE to develop FreeCAD code.

Sal
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Using PyCharm as editor

Postby more11 » Tue Aug 02, 2016 1:43 am

Thanks Sal

I am just trying to use PyCharm as editor. It doesn't work with version 0.15 or 0.17. My current version is;

Code: Select all

OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8020 (Git)
Build type: None
Branch: master
Hash: 62a8828dc8603a9387a5fa1d9eb41bc4cf12cb62
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17


Mårten
Point taken :-)
User avatar
salp
Posts: 240
Joined: Thu Nov 21, 2013 11:58 pm
Location: Putnam, NY

Re: Using PyCharm as editor

Postby salp » Fri Aug 05, 2016 1:38 am

Marten,

I just want to clarify that i understand your question. You want to use PyCharm editor and configure it so that it shows you what is available inside the module that has been imported. First I wanted to mention that I was NOT able to configure PyCharm to work, however I went away and did a little research and found that Eclipse with PyDev works.

I installed the IDE including the PyDev module and then created a new project as shown in the next 3 images.
NewProject_1.png
NewProject_1.png (61.79 KiB) Viewed 5212 times
NewProject_2.png
NewProject_2.png (38.42 KiB) Viewed 5212 times
NewProject_3.png
NewProject_3.png (92.95 KiB) Viewed 5212 times
Finally I created a file and entered 2 lines of code
import FreeCAD
FreeCAD.
After you enter the dot, the window opens and shows all the functions inside the FreeCAD module.
NewProject_4.png
NewProject_4.png (110.4 KiB) Viewed 5212 times

Is this what you were expecting?


OS: Ubuntu 16.04.1 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8066 (Git)
Build type: None
Branch: master
Hash: 4de1b39b4f428200241f726fe32d77a1f6bcc30a
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

Sal
more11
Posts: 115
Joined: Sun Sep 28, 2014 11:03 am

Re: Using PyCharm as editor

Postby more11 » Fri Aug 05, 2016 7:53 am

Thanks Sal. I will try this.
Point taken :-)