No intellisense import suggestions for a module - visual-studio-code

vscode doesn't give any Code Action import suggestions for a specific python module I install in the python environment (it's a module I created). I can manually add the import - works. I get import suggestions for all other modules I installed . I can also follow up code into the module (after I have the import, go to definition works). It seems it's only missing as a source of import suggestions.
Is the module missing something?

Related

Cannot import sparknlp on Databricks

I'm trying to do an
import sparknlp
on the Databricks platform and I'm getting a similar message to the one reported at After installing sparknlp, cannot import sparknlp
I can't figure out how to get the python wrapper installed... I can access the spark-nlp library via Scala but I can't get the python version working. Any tips would be greatly appreciated!
These error can be produced due to sparknlp jars have been loaded correctly, but python wrappers library can not be imported. Make sure you have installed those wrappers correctly. Check out the sparknlp documentation site
As is said in documentation webpage, make sure that after install python sparknlp library:
pip install --index-url https://test.pypi.org/simple/ spark-nlp==1.5.4
that your environment variable PYTHONPATH can locate sparknlp wrappers.

ImportError: No module named sympy

I am getting the following error while trying to run a sympy file in order to contribute to sympy. It is :
ImportError: No module named sympy
I installed the sympy module through pip for both python2.7 and python 3.
Also, isympy is working.
Strangly, when I try to import sympy in python's interactive console in the main sympy directory, no import errors are shown but in some other directory, it shows import errors.
Please help me to download the sympy module in a way that I will be able to run the code.
Thanks.
Importing module in python console of main directory.
Importing module in some other directory.
A likely cause here is that you are using two different Pythons. If you have Python installed multiple times (like Python 2 and Python 3), each has its own separate packages. You can check what Python you are using by printing sys.executable.
I should point out that for the purposes of contributing to SymPy, you generally want to run against the development version. That is, running Python from the SymPy directory and importing the development version from there, without actually installing it.
Thanks for the reply.
But I solved the problem. I realised that I didn't install sympy in the current conda environment. When I tried it using the command:
conda install sympy
It worked and no error is being shown.
Thanks.

What is the structure of import function in Python?

I am searching to do a little programm with 3D animations for one homework for my school.
I work in Spyder space from Anaconda(Python) .
I want to import for that the module vpython installed by pip.
The first line of the function " from visual import * " doesn't work whereas in all examples found on the web, all the programms begins by this line for calling the whole function of this module. Also, i have seen different path and files "vpython" installes on my PC in the path Anaconda3.
So, for me, python don't arrive to find the good path with "import".
Have I to uninstall and install again Python and Anaconda or this is just a problem of grammary from me on my programm and i must help the function import to find the good path, writing some new instructions?
Thanks to have read and i wish you have one idea of what is wrong in this because for the moment I'm blocked.
In Jupyter/iPython/Anaconda, the import should be
from vpython import *
In classic VPython, it's
from visual import *

How to import a Cython Module into IPython Notebook and compile it

I am using IPython and Cython.
I am editing my Cython functions in modules in an external text editor.
I would like to import these modules and use them in IPython, but with IPython compiling them when importing.
What is the syntax for doing this? I do not want my code inside my IPython notebooks.
This is an unusual workflow but it should be possible to get something working. Firstly, for things to be importable in your IPython session, they must appear in sys.path. You can insert new folders in that list like this:
The path you would be adding would be the folder(s) in which your compiled Cython modules would be placed. Whichever of the next strategies you use, at a minimum the path to your compiled (.pyd) Cython modules needs to be on sys.path to be able to be imported.
Secondly, you need a way to compile your Cython modules. If you're using the recommended approach, you would have a setup.py file with your cython sources and python setup.py build_ext to produce the compiled .pyd files. You would have to restart your IPython Kernel every time you recompiled your Cython modules.
There are alternatives to setup.py. One of them is my easycython which is a command-line tool that compiles .pyx source into .pyd without needing a setup.py. This tool is AFAIK only used/tested by me, so it may not work, ymmv etc. You would still have to restart your IPython Kernel every time you recompiled your Cython modules. (I mention it here only because it is one of my babies.)
A better approach would be to use pyximport, because it will compile on demand and has reload support:
# This is inside your IPython Notebook
import pyximport
pyximport.install(reload_support=True)
import my_cython_module
You can reload the module with
reload(my_cython_module)
You could try to be clever with some kind of logic to make it so that simply rerunning the notebook will either reload or import:
# Speculative code: I have not tried this!
# This is inside your IPython Notebook
import pyximport
pyximport.install(reload_support=True)
if 'my_cython_module' in dir(): # Maybe sys.modules is better?
reload(my_cython_module)
else:
import my_cython_module
You may have to play around a bit to find something that works, but something should be workable for your use-case.

How can I import a .PYD module in IronPython?

I'm trying to use a python package from IronPython.
Everything works fine if I import regular python modules.
But when I try to do the following:
import win32ui
I get:
No module named win32ui
I've hunted through the code in IronPython.Runtime.Importer and there's no mention of .pyd
Anyone know a way around this?
You can check out IronClad which is working to provide this support. It may or may not work w/ your PYD of choice.
A .pyd file is a DLL. So unless IronPython (which is written in .net) can correctly load C DLLs written for CPython, you might be out of luck.
Update
In fact, according to the IronPython FAQ, you are unfortunately unable to import .pyd files:
Q: How do I build and call into PYD libraries?
A: IronPython does not support using PYDs built for CPython since they
leverage implementation details of CPython. You can get a similar
effect for new "PYD"s you would like to implement by writing them in C#
or VB and building a DLL for .NET.