Pylint in Neovim using Mason and null-ls cannot load packages - python

I was hoping you would be able to help me get pylint fully functional in nvim.
Env:
Mac OS Venture 13.1
nvim v0.8.1
pylint 2.15.9
python 3.11.1 (accessed through 'python3')
pip 22.3.1 (accessed through 'pip3')
I am using the latest versions of null-ls and Mason and the related libraries to tie all of this together.
My problem is that pylint does not recognise any of the packages I have fetched with pip3. My code executes as expected when I run it using python3, so the packages are installed and the modules are loaded correctly. I have checked :Mason in nvim and it has access to the right python and pip executables.
If I install pylint outside Neovim, it gives me the same error. I can correct it by running it with --init-hook="import sys; sys.path.append('/Library/Fr...)" which points to the directory where pip3 saves the packages that are installed.
How do I check which paths pylint uses to search for packages to import? And how can I neatly add the right paths to direct it to the correct place?
I seem to be missing some fundamental piece of information to understand the problem. Any ideas?
Thank you all so much for the help and support! <3 And I look forward to continue my coding journey!

Related

Trying to check my Python packages but keeps telling me that aiohttp is not installed

I am trying to check what packages are installed in my virtual environments, I have different packages from different virtual environments depends on what project I am working on. Whatever virtual environment I switch I always get this error when using help("modules")
aiohttp dependency is not installed: No module named 'aiohttp'. Please re-install black with the '[d]' extra install to obtain aiohttp_cors: `pip install black[d]`
My question is how do I install this package correctly, and by that I mean should I install it in my main Python PATH? I'm not sure if this is a mandatory package that I need it installed in my main environment if that makes sense.
My Python version is 3.9.6 by the way.
EDIT: I was able to fetch all of my packages.
I had to do a . Scripts/activate first, but it was weird because before I did not have to do the activate command before, since VS Code displays on the lower left portion of the screen what environment you are currently using, I'm not sure if I had any settings change prior to this bug.
Maybe you should try to open new terminal

python can't find module 'python-for-android'

I am trying to compile my python program into an android APK file. I installed the package 'python-for-android'. when i tried to use it, i go an error saying C:\Program Files\Python39\python.exe: No module named python-for-android. Can someone please tell me what is going wrong?
https://pypi.org/project/python-for-android/
It looks like it is being installed into a different location than where you pip installed the library. If you can give more details about how you installed the package, it might help identify the issue.
Is it possible that you have two python versions, and it installed it into the wrong version.
Using virtual environments might make it easier to understand what is going on. If you pip install into a virtual environment, you can be pretty confident that it is installing into the correct version of python.

How do I resolve #error: architecture not supported during pip install psutil?

I've run into some problems while trying to download packages with pip. Namely, when I run
pip install "dask[complete]"
on MacOS Catalina 10.15.7. Specifically, the package that throws this error is psutil.
I run into an #error: architecture not supported message. I believe this is because the installer is looking for the MacOS 10.14.6 SDKs, but I am on 10.15.7. One user on this post stated that installing a new Python 3 fixed the issue. Maybe this is because the newer Python comes with a cached version of the package that uses the MacOS 10.15.7 SDKs.
I'm guessing that there might be two solutions to this issue:
Download a non-cached version of psutil, which might be compatible with the version of Python I'm using as well as MacOS Catalina.
Download a newer version of Python 3, namely 3.8.5+, and replace the Xcode Python 3 with this version, enabling me to stay up-to-date with current Python and packages.
I'm wary of the second method because of any possible dependencies I will lose while updating, and I've also been made very aware through research that generally speaking, you don't want to mess with system Python installations.
I'm not opposed to being walked through the first solution, if it would indeed solve the problem, but am very curious about the second solution, again, if it is possible. If neither approach would work out as intended, has anyone encountered this issue and resolved it without using a fresh, SEPARATE install of Python? I don't really want to start messing with virtual environments, but if I must, I supposed I will just download PyCharm and restart there.
EDIT: After continuing to try to work around the issue, I've been led to believe that it is not being caused by an outdated version of psutil; could it be an outdated version of setup.py? In this case, would it indeed be an issue with an old Python version? I'm very new to configuring Python in depth like this, any help would be greatly appreciated.
Try setting the environment variable ARCHFLAGS="-arch x86_64" so Xcode 12 doesn't try to build an ARM64 universal binary. It worked for me on a different python package that had the same error.
ARCHFLAGS="-arch x86_64" pip install "dask[complete]"
(Thanks to Keith Smiley's comment at on Bitbucket for pointing this out.)

How do I change the kernel/python version for iPython?

I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.

Python namespace packages on Ubuntu 11 with setuptools 0.6c11

Hi fellow Python programmers,
I recently felt the urge to update my operating system, and wiped out the existing Ubuntu 10 install for 11.10. I was already using python 2.7 on the older system. After I set up the prerequisites for our code base, I created a virtual environment, and ran python setup.py develop to install the dependencies for the code base. Everything ran smoothly, but when I tried to start the app, python was unable to import some packages which were successfully installed. These are namespace packages, such as repoze.what.
The weird thing is, I looked at the version of setuptools that we are using on our deployment system, and it is the same as on my machine (0.6c11). I'm at a loss as to where the difference may be, and what is causing the problem.
One thing that I tried is to create the virtual environment using distribute instead of setuptools, but that did not help.
Any help would be highly appreciated, since this is holding me back from doing any serious work.
Cheers, and thanks in advance.
This discussion suggest that you may want to list setuptools explicitly as a dependency for a package that has namespace packages. I found out that my packages (which also have namespaces) install well with pip, but sometimes cannot be imported if installed by easy_install.

Categories