-2

I need python3.6 for tensorflow installation, so I downloaded python3.6.12.tar. And I found that I should pip install tarfile. However, in this case it is an older version of python. FYI, In my computer(laptop) I installed python3.9. My question is: can I pip install python.tar inside a virtualenv?

phd
  • 82,685
  • 13
  • 120
  • 165
Andy
  • 13
  • 3
  • No, you cannot install Python with `pip`. – phd Dec 14 '20 at 14:54
  • I'm trying to "setup.py install" right now but it gives me some kind of error... – Andy Dec 14 '20 at 15:10
  • Traceback (most recent call last): File "blahblahblah\Python36\setup.py", line 29, in set_compiler_flags('CFLAGS', 'PY_CFLAGS_NODIST') File "blahblahblah\Python36\setup.py", line 27, in set_compiler_flags sysconfig.get_config_vars()[compiler_flags] = flags + ' ' + py_flags_nodist TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' – Andy Dec 14 '20 at 15:11
  • https://github.com/python/cpython#build-instructions – phd Dec 14 '20 at 15:30
  • https://stackoverflow.com/search?q=%5Bpython%5D+build+python+from+sources – phd Dec 14 '20 at 15:33
  • Yes I can install another version of python now. ty. – Andy Feb 03 '21 at 18:34

1 Answers1

1

This is not how virtual environments work. I suggest you to do a little bit more research on virtual environments in Python.

Virtual Environments and Packages

Basically you need to install the necessary python version onto your machine. Then go ahead and use that specific python (which is version 3.6 in your case), to create a virtual environment with the command

~ /usr/bin/<path-to-python3.6> -m venv venv

This command will create a folder called venv. Now you need to source the activation script inside this folder to activate your environment.


Handy note: if you are dealing with different versions of python, a more robust way of handling such situations is via using a tool called pyenv.

BcK
  • 2,548
  • 1
  • 13
  • 27