1

I have a module that I want to be able to import from any script without doing any sys.add_path and similar stuff. I want it to be permanently added.

Since I installed Python with anaconda, I have a anaconda3 folder added to Path under System variables. In the same place I added C:\Users\lukas\anaconda3\package and in the package folder is my script with empty init.py, and the script.py which contains functions.

In the Path under User variables, I already had anaconda3 folder, and I added the \anaconda3\package. Also, I created the PYTHONPATH variable under User variables and added anaconda3 and \anaconda3\package.

When I open my CMD, that is working in C drive, it can import the package successfully. But, when I open the CMD in D drive(in my VS code) it is not working, can't import the package.

As you can see, I've tried everything I saw on the internet, and probably now I have much more junk than needed added paths.

How should I clean this up and make it work on every drive?

Luka Savic
  • 101
  • 1
  • 11

1 Answers1

0

For anyone that is interested, after several hours, I tried again(by accident) and everything works :) It seems like Win10 needed some time to really update the environment variables.

Luka Savic
  • 101
  • 1
  • 11
  • 1
    When you change the environment variables using Control Panel, that doesn't affect anything that is currently running. You'd have to close and re-open VSCode for it to see the change. – Tim Roberts Apr 04 '22 at 23:55
  • @TimRoberts thanks for the info... totally makes sense. In a hurry, I wanted everything to work in a second, and didnt think about that. Thanks – Luka Savic Apr 04 '22 at 23:58