My Python VSC does not recognise Ursina - everything regarding that engine is underlined with yellow

73 Views Asked by At

I have tried importing ursina through cmd multiple times, updated pip, added newest python directories to path.

Ursina does not want to work, still.

I have tried the help that existing posts on here provided, but no solutions worked.

I installed ursina through cmd, and expected that when I did this:

from ursina import *

in the beginning of my code, it would import. It did not.

1

There are 1 best solutions below

0
On

(check just in case) If from ursina import * is the only line being caught, it's probably your linter complaining about code efficiency and security. I haven't had these problems neither on my Windows PC nor my MacBook Pro (pyenv).

If not, try these:

1. Make sure ursina is installed to the virtualenv (or Python environment) you are trying to run it in. Use Ctrl + Shift + P to pull up the command bar in VSCode, then press enter on Python: Select Interpreter and make sure the correct environment is selected.

2. Make sure you're not running pip or python with administrator privileges. This is the same with sudo on *nix devices working with python, as ursina could be installed to the Administrator account, or root as a Linux example.

3. Make sure ursina is actually installed through pip freeze. In some cases, pip may glich and not actually install packages correctly. Try running the command pip freeze and search for ursina==VERSION. If it is not there, you should try reinstalling Python (with pip). If that does not work, try downloading someone's copy of their ursina folder in their site-packages directory to install ursina without pip.

4. Try upgrading pip. If there was a network issue, PyPI servers may have encountered an issue with ursina or other packages, and thus may have redirected clients to install wrong packages or even none at all. Run the following command to upgrade your pip version: python -m pip install --upgrade pip, or in recent Python versions, pip install --upgrade pip.

5. Try creating a virtualenv, or venv. Some packages might argue with the ursina version you're trying to install, and thus may make a collision occur. Creating an isolated Python environment for each of your Python projects can save you from errors like these. I advise you create a new virtual environment through python -m venv, activate the venv, then installing ursina to a fresh, clean environment dedicated for your ursina project.

6. If none works, try reinstalling Python and pip completely. Save your global packages through pip freeze and save it to a file on your desktop (or anywhere you want), and reinstall Python and pip from the official python website. Your venvs will stay intact, only your global packages will be reset, or in other words, your site-packages folder. After reinsalling, with the pip freeze output, reinstall a few of your packages at a time to check whether ursina works or not. It is best to use virtualenvs for all your projects, so you can either take the time to split up your Python environments, or simply combine all for simplicity.

If you tried all of these, or have difficulties/errors while doing them, leave a comment and I'll try to see what's going on.

Quick Edit: You could also try reinstalling your Python-related VSC extensions, including IntelliSense, maybe that could refresh their package lists.