0

In my work I have installed python, but to work on other project I am supposed to use python interpreter with some tweaks, which is fine, but packages inside are trying to access packages in python, which is in system directory, numpy to be precise. I changed in powershell the pythonpath to be

PYTHONFOLDER="path/to/python/folder"
PYTHONPATH=%PYTHONFOLDER%\Lib;

But the results are same. Can I turn existing directory into virtual one? Can I specify where to get packages to python? Thanks

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • What tweaks ? Also you needn't define PYTHONPATH like that - Python by default always looks into it's own lib directories to find what it is trying to install. PYTHONPATH is intended for your personal modules/packages. It isn't clear what you mean that numpy is installed in the system directory - where exactly ? – Tony Suffolk 66 Aug 31 '20 at 14:30
  • I downloaded python with numpy inside in C:\tweakedPython\site-packages but numpy is opened from C:\Users\user\AppData\Roaming\Python\Python37\site-packages\numpy which because of different versions give [WinError 193] %1 is not a valid Win32 application – Antonín Procházka Aug 31 '20 at 14:51
  • So where is Python installed - and how did you 'download python with numpy 'installed - that isn't clear to me. – Tony Suffolk 66 Aug 31 '20 at 15:00
  • Python is normally installing packages to the one path, I downloaded a zipped version of python somebody else installed, where the person already installed all the packages with correct version etc. with some tweaks i was told. – Antonín Procházka Aug 31 '20 at 15:14
  • I would simply use pip to install the packages - rather than download sonething that someone else has built; but that is just me. – Tony Suffolk 66 Aug 31 '20 at 19:33

1 Answers1

1

In this case I would recommend using virtual environments. This will allow you to have separate sets of packages (with unique versions) for each project.

Paul D.
  • 591
  • 7
  • 17
  • But my question was if I can turn downloaded python with its packages into a virtual enviroment. – Antonín Procházka Aug 31 '20 at 14:52
  • Normally - you create a Virtual environment based on a specific version of Python and once the VE is created you use pip to install the packages directly into that virtual environment. You DON'T need to download python again. – Tony Suffolk 66 Aug 31 '20 at 15:01
  • I know that you don't have to install python again. I have large number of packages and I am asking if I can use them and only them. – Antonín Procházka Aug 31 '20 at 15:16
  • When you create a virtualenv, you get an option as to whether system packages remain available inside it. Look at `virtualenv --help`. – Charles Duffy Aug 31 '20 at 15:40
  • @AntonínProcházka Please read the documentation on virtual environments. That should answer all of your questions on this. – Paul D. Sep 01 '20 at 14:26