# Python modules librarys packages load problems on IDEs Visual Code

**URL:** <https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377>\
**Category:** Ask Fedora\
**Tags:** f37, vscode, python\
**Created:** [January 2, 2023, 10:43pm UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377 "2023-01-02T22:43:22Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![isudoajl](https://avatars.discourse-cdn.com/v4/letter/i/3c6eb4/32.png) [@isudoajl](https://discussion.fedoraproject.org/u/isudoajl)\
**Post date:** [January 2, 2023, 10:43pm UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/1 "2023-01-02T22:43:22Z")

</div>

Hello, Im using pip to download packages but that dependencies only works when I try from the CLI

```auto
Type "help", "copyright", "credits" or "license" for more information.
>>> import mysql.connector
>>> 

```

But when I try from Visual Code it does not work.

I already tried this matter of selecting the correct interpreter, I also tried creating virtual env and selecting the binary inside it and nothing. I try from Eclipse IDE too and is the same problem.

 ![729966f8792b4cb0817a8ac34d1449f61709b902.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/1/4/14715d245e46d998f98974e44d9ae92c97209ff5.png)

```auto
Import "mysql.connector" could not be resolvedPylancereportMissingImports

```

Any suggestion?

---

<div class="post-metadata">

**Author:** ![computersavvy](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/computersavvy/32/4741_2.png) [@computersavvy](https://discussion.fedoraproject.org/u/computersavvy)\
**Post date:** [January 3, 2023, 12:04am UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/2 "2023-01-03T00:04:22Z")

</div>

`dnf list installed python3* | grep -i mysql`

Installing python packages with pip as root can easily corrupt your installation since pip does not understand nor respect the package installed files and may overwrite them. Using pip should always be done as user (not using su or sudo) or in a venv.

You also should be aware that that image shows python 3.10 and F37 is on python 3.11.

In a venv you can set a python 3.10 environment to support VS

---

<div class="post-metadata">

**Author:** ![isudoajl](https://avatars.discourse-cdn.com/v4/letter/i/3c6eb4/32.png) [@isudoajl](https://discussion.fedoraproject.org/u/isudoajl)\
**Post date:** [January 3, 2023, 12:08am UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/3 "2023-01-03T00:08:58Z")

</div>

Thanks in advance for your time.

> [@computersavvy](#):
>
> Installing python packages with pip as root can easily corrupt your installation

After trying many times as a normal user and not being able to solve it then try as root 😕 but so far I haven’t seen any strange behavior after that.

> [@computersavvy](#):
>
> dnf list installed python3\* | grep -i mysql

No output.

> [@computersavvy](#):
>
> You also should be aware that that image shows python 3.10 and F37 is on python 3.11.

Yes! I could notice this! But but I didn’t quite understand, what should I do here?

---

<div class="post-metadata">

**Author:** ![computersavvy](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/computersavvy/32/4741_2.png) [@computersavvy](https://discussion.fedoraproject.org/u/computersavvy)\
**Post date:** [January 3, 2023, 1:39am UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/4 "2023-01-03T01:39:25Z")

</div>

I have not used VS code so cannot immediately answer. I do have it installed.  
Maybe if I had your exact code modules for what you are developing I could test but without that I would only be guessing.

My earlier comments are about what may happen, not what will happen in every case.

Having upgraded my system from F34 to F36 then F37 I have the older 3.10 python installed as well as 3.11.

My visual studio code as installed shows this in the help-about tab

```auto
Version: 1.74.2
Commit: e8a3071ea4344d9d48ef8a4df2c097372b0c5161
Date: 2022-12-20T10:27:19.253Z
Electron: 19.1.8
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Linux x64 6.0.15-300.fc37.x86_64
Sandboxed: No

```

and was updated just a week ago.

---

<div class="post-metadata">

**Author:** ![qulogic](https://sea1.discourse-cdn.com/fedoraproject/user_avatar/discussion.fedoraproject.org/qulogic/32/458_2.png) [@qulogic](https://discussion.fedoraproject.org/u/qulogic)\
**Post date:** [January 3, 2023, 3:00am UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/5 "2023-01-03T03:00:30Z")

</div>

VSCode says it is running Python from the `python-virtualenv` venv. Are you running from the same venv in the CLI? Did you install using pip _from that venv_?

And `dnf` is irrelevant here since VSCode is not using system packages.

---

<div class="post-metadata">

**Author:** ![erickbezerra](https://avatars.discourse-cdn.com/v4/letter/e/b193c8/32.png) [@erickbezerra](https://discussion.fedoraproject.org/u/erickbezerra)\
**Post date:** [January 7, 2023, 1:09pm UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/6 "2023-01-07T13:09:04Z")

</div>

I’m with the same problem of Elliott but I have the last version of python and VS Code installed.

---

<div class="post-metadata">

**Author:** ![isudoajl](https://avatars.discourse-cdn.com/v4/letter/i/3c6eb4/32.png) [@isudoajl](https://discussion.fedoraproject.org/u/isudoajl)\
**Post date:** [January 9, 2023, 1:24am UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/7 "2023-01-09T01:24:43Z")

</div>

Sorry, I started this post and I was away for several days, my wife came on vacation and among other things anyway…

I’ve been there for several days within what time has allowed me and I discovered several things that solved my problem with both Eclipse and VSCode:

With Eclipse:  
After you install PyDev the first thing you need to do is go to _Windows-Preferences-Interpreters-Python Interpreters_ and select the python interpreter.

What is the problem here?

If you select _Choose from list_

 ![99fd949001ca564fdcc48288815a815381082ec4.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/9/9/99fd949001ca564fdcc48288815a815381082ec4.png)

he will show you the default python binaries:

 ![0f5c4dc3b38d73cef5d599b875ac8a721cd21cbd.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/0/f/0f5c4dc3b38d73cef5d599b875ac8a721cd21cbd.png)

After selecting one of them automatically he select the main libraries

 ![cce59e8e7eb975bc453c2619f0ba7cdf205c26b8.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/c/c/cce59e8e7eb975bc453c2619f0ba7cdf205c26b8.png)

Acepting this configuration we find a problem, the problem occur when we start downloading packages using `pip` command WITHOUT sudo bc is not recomendable, so when we download any package example:  
`pip install mysql-connector`

He will install that packages under your home directory:  
`/home/isudovm/.local/lib/python3.11/site-packages`

If you notice the previous full path name was `/usr/bin/python3.10` and this one is `/home/isudovm/.local/lib/python3.11/site-packages` and it won’t work when you run your code.

Solution:  
Select _New-Browse for python/pypy_ and manually select `/usr/bin/python3.11`

 ![c35027dcd473146e93653f0ee7937ed224066ee0.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/c/3/c35027dcd473146e93653f0ee7937ed224066ee0.png)

Select proceed anyways after selecting `/usr/bin/python3.11`

 ![5deba224f5d4b2f9b9349055f108a5e97f729e43.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/5/d/5deba224f5d4b2f9b9349055f108a5e97f729e43.png)

And tha’s it. Works for me!

With VSCode:

You need to create first a venv if you dont know what is, google it.  
After making some test I realize that when I create this venv from my terminal I dont know why didnt work, but when I create the venv using the VSCode directly then works.

![9aed3f3fb19369b594eecb2d585f9e692a256092.png](https://us1.discourse-cdn.com/fedoraproject/original/3X/9/a/9aed3f3fb19369b594eecb2d585f9e692a256092.png)

After create the venv using VSCode activate the venv from the VSCode terminal and then use pip command to download the package you need and for me worked!

If any have any doubt please let me know.

---

<div class="post-metadata">

**Author:** ![erickbezerra](https://avatars.discourse-cdn.com/v4/letter/e/b193c8/32.png) [@erickbezerra](https://discussion.fedoraproject.org/u/erickbezerra)\
**Post date:** [January 9, 2023, 2:43pm UTC](https://discussion.fedoraproject.org/t/python-modules-librarys-packages-load-problems-on-ides-visual-code/75377/8 "2023-01-09T14:43:44Z")

</div>

Hope that your wife get well as soon as possible!

About the problem, I found this:  
[https://github.com/microsoft/vscode-python/issues/20253](https://github.com/microsoft/vscode-python/issues/20253)

I’m thinking in using another IDE.
