acitoolkit not working with Pycharm, why?

I've installed acitoolkit through Gitbash which is the terminal I'm using with Pycharm. When i try to run an acitoolkit query through Gitbash it works fine like this
>>> from device_info import apic
>>> print(apic)
{'host': 'https://sandboxapicdc.cisco.com', 'username': 'admin', 'password': 'ciscopsdt', 'port': 443}
>>> from acitoolkit.acitoolkit import *
>>> dir()
['AnyEPG', 'AppProfile', 'AttributeCriterion', 'BGPSession', 'BaseACIObject', 'BaseContract', 'BaseInterface', 'BaseMonitorClass', 'BaseSubnet', 'BaseTerminal', 'BridgeDomain', 'CollectionPoli
cy', 'CommonEPG', 'ConnectionError', 'Context', 'Contract', 'ContractInterface', 'ContractSubject', 'Credentials', 'EPG', 'EPGDomain', 'Endpoint', 'Fabric', 'FexInterface', 'Filter', 'FilterEn
try', 'IPEndpoint', 'InputTerminal', 'Interface', 'InterfaceStats', 'L2ExtDomain', 'L2Interface', 'L3ExtDomain', 'L3Interface', 'LogicalModel', 'MonitorPolicy', 'MonitorStats', 'MonitorTarget'
, 'NetworkPool', 'OSPFInterface', 'OSPFInterfacePolicy', 'OSPFRouter', 'OutputTerminal', 'OutsideEPG', 'OutsideL2', 'OutsideL2EPG', 'OutsideL3', 'OutsideNetwork', 'PhysDomain', 'PortChannel',
'Search', 'Sequence', 'Session', 'Subnet', 'Table', 'Taboo', 'Tag', 'Tenant', 'TunnelInterface', 'VMM', 'VMMCredentials', 'VMMvSwitchInfo', 'VmmDomain', '__annotations__', '__builtins__', '__d
oc__', '__loader__', '__name__', '__package__', '__spec__', 'apic', 'attrgetter', 'build_object_dictionary', 'copy', 'itemgetter', 'log', 'logging', 're', 'session', 'sys', 'tenants', 'urlenco
de']
>>>

when I yty to run the same query through Pycharm i get this
from device_info import apic
print(apic)
{'host': 'https://sandboxapicdc.cisco.com', 'username': 'admin', 'password': 'ciscopsdt', 'port': 443}
from acitoolkit.acitoolkit import *
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\M7551873\netprog_basics\network_controllers\aci\acitoolkit\acitoolkit\__init__.py", line 33, in <module>
from .aciTable import Table # noqa
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "C:\Users\M7551873\netprog_basics\network_controllers\aci\acitoolkit\acitoolkit\aciTable.py", line 33, in <module>
from tabulate import tabulate
File "C:\Program Files\JetBrains\PyCharm Community Edition 2020.3\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'tabulate'

 

Why is that ?

 

12 comments
Comment actions Permalink

Perhaps there are some environment variables or paths that are missing in PyCharm.
Have you checked if PYTHONPATH is the same in PyCharm and in Gitbash (apart from PyCharm-specific folders of course)?

0
Comment actions Permalink

Hello. Here is my Path for the current project i want to use

From Pycharm it says its C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv|Scripts\python.exe
I then fire up terminal FROM Pycharm and Gitbash goes to
C:\Users\M7551873\netprog_basics\network_controllers\meraki

 

So now I've changed on Gitbash to
C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\Scripts
it wont let me change it to C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\Scripts\pythone.exe
because python.exe isn't a directory so should it just work with
C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\Scripts   ?

 

 

0
Comment actions Permalink

It WAS the Path, it is now working the way I want it to, i just had 

From C:\Users\M7551873\netprog_basics\network_controllers\meraki

To C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\Scripts

 

I wrongly assumed that Pycharm would automatically give Gitbash which is my chosen terminal the full path.

Do you know why it doesn't do that and is there a way you can force it from Pycharm to automatically add the full path or will I always have to do it manually ?

 

Thank you so much for your help, you wouldn't believe how long this has took me to fix, it's been really frustrating, but I've learned a lot which is the main thing.

0
Comment actions Permalink

Where exactly did you change that path? In PyCharm's terminal settings?

0
Comment actions Permalink

I found the path C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\Scripts\python.exe in Pycharm. that is what it told me in Pycharm

If i then clicked on terrminal from Pycharm it opend GitBash in C:\Users\M7551873\netprog_basics\network_controllers\meraki       
So I added the \venv\Scripts     to Gitbash

is there a way Pycharm can autoamtially add the FULL correct directory path, you know add the \venv\Scripts ?

0
Comment actions Permalink

C:\Users\M7551873\netprog_basics\network_controllers\meraki - this is probably your project?
PyCharm adds it by default because Add content roots to PYTHONPATH is enabled in your run configuration (Run | Edit Configurations...).

If you need a specific directory to be found by Python, then one of the options is to do it from PyCharm's settings. Namely, you can use Interpreter Paths https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-reloading-interpreter-paths.html
Does it cover your case?

0
Comment actions Permalink

So either way I have to add the full path manually is what you're saying yes?
i can change it on Pycharm to C:\Users\M7551873\netprog_basics\network_controllers\meraki
and everything will still work ?

 

Or i change it to C:\Users\M7551873\netprog_basics\network_controllers\meraki\venv\scripts in Gitbash
again, this is a manual change yes?

0
Comment actions Permalink

In this case, I believe these are the only two options, yes.

I'm not sure what exactly is the root cause of the problem so can't think of a more elegant solution at the moment. Could you check if enabling Emulate terminal in output console for you run configuration helps?

Also, to clarify, you've configured Gitbash in PyCharm's terminal settings, right?

0
Comment actions Permalink

Hello. yes Gitbash is the terminal.

Where do i Emulate terminal in output console ?

0
Comment actions Permalink

Run | Edit Configurations...

---

Do you see your venv activated when you open the terminal in PyCharm?

0
Comment actions Permalink

I open Pycharm in whatever project, then i click on the terminal button which then opens gitbash

gitbash opens in the follwing directory

C:\Users\M7551873\netprog_basics\network_controllers\whatever

I then eeed to CD to

C:\Users\M7551873\netprog_basics\network_controllers\whatever\venv\Scripts

 

 

0
Comment actions Permalink

The start directory can be changed in File | Settings | Tools | Terminal.

The default start directory for new projects can be changed in File | New Projects Settings | Settings for New Projects.

 

0

Please sign in to leave a comment.