1

Sorry in advance if this question has been asked before,

So after some time, I wanted to start a new python project. My previous computer (on which my python files were) died. I had saved my projects in my Dropbox. Now I installed python (3.8, there is also an anaconda installation, but it should not interfere with the python installation) on my new PC, and I cannot import any library to those files.

The python shell can find the imported packages (imported using pip), but even when I move the files to C:\Users\Username\AppData\Local\Programs\Python\Python38-32\Scripts (single user installation). It doesn't work.

I have tried uninstalling and re-installing pygame (in this example. Any library is unusable) using pip, pip3 and even pip3.8, I have added the .whl file by hand, it all didn't work. I have tried a virtual environment, but I can't get that to work either.

I run Windows 10 on a 64-bit computer.

Lelebees
  • 13
  • 5
  • How do you start Python3? Have you run pip explicitly from your desired interpreter version, e.g. ``python3 -m pip install ...``? – MisterMiyagi Feb 21 '20 at 08:27
  • hope these help you https://stackoverflow.com/questions/51415425/cannot-import-module-in-same-directory-and-package/51416465 and https://stackoverflow.com/questions/14132789/relative-imports-for-the-billionth-time/14132912#14132912 – Paul Feb 21 '20 at 08:33
  • @MisterMiyagi, you might be onto something. While using ```python3``` generated no output, uninstalling with plain ```python``` generated a lot of red text. Mostly permission errors... – Lelebees Feb 21 '20 at 08:36

1 Answers1

0
  1. first be sure you know which python installation you use with which import files etc.
  2. you can copy your files not in scripts, but in lib somewhere in site-packages dir.
  3. add your scripts to the python path! sys.path.add(.....) Otherwise python is blind and can't see them
Petronella
  • 2,327
  • 1
  • 15
  • 24
  • I do not have a site-packages directory, but I do have ```libs``` and ```Lib``` in my main python directory, Lib contains files like ```datetime.py```, libs contains ```.lib``` files. Is one of those the right directory? – Lelebees Feb 21 '20 at 09:50
  • Also, how do I use sys.path.add(...)? Using it in cmd didn't work, neither did using it in the python shell. – Lelebees Feb 21 '20 at 10:03
  • https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory and https://askubuntu.com/questions/470982/how-to-add-a-python-module-to-syspath You migh want to ask google first then here. – Petronella Feb 21 '20 at 10:49
  • It started working in the global ```site-packages``` dir. – Lelebees Feb 21 '20 at 13:52