I know there are some solutions in the internet but I couldn't find an end to end solution and I am pretty skeptical about doing things wrong so asking here for a complete solution.
I have recently installed debian10 and it comes with python2.7 and python3.7. I want to install python3.6 but not as a new python but as an isolated one using virtualenv (that I got from internet as I have python3.7 and venv can only install the same python version).
I couldn't understand that do I need to install python3.6 first in my system and then use virtualenv or I can directly install virtualenv using pip3 (I prefer pip) of python3 and install it. Also in either of the cases do I need to somehow fetch the source code for python3.6 and if yes then do I need to build it locally first then use virtualenv or not. A detailed step wise solution will be better along with if any changes need to done in the .bashrc file.
I am new in Linux and python environment and still learning. Any help will be appreciated.
Thanks in advance.
P.S.: If you find that I need to explain more or you need some clarifications kindly comment it instead of down voting first. I will try my best to modify my question accordingly.
Related
Being a "normal" user (i.e. not overly familiar with code), I find myself in a bit of a python conundrum and would very much like to try to muster some kind of assistance with the following:
I use svtplay-dl and youtube-dl via homebrew in Mac OSX 10.14.6, which also requires python (among many other extensions such as ffmpeg et al). However, I now seem to have three different python versions installed, and since python3.5 is no longer supported, I thought I would delete this and make sure that homebrew/svtplay-dl/youtube-dl uses a path to python3.9.
When I type "which" followed by the following in Terminal:
python
python3.5
python3.9
...I get the following respective results:
/usr/local/bin/python
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
/usr/local/bin/python3.9
Based upon this short background info, can someone advise how I best uninstall/remove python3.5 and get homebrew et al to use python3.9 every time python is required?
Any help with this would be very much appreciated!
/Mark
The normal answer is to use something like virtualenv (https://virtualenv.pypa.io/en/latest/) to isolate your python environment and dependencies locally.
You need to install virtualenv on your system, then you tell it what python version to install. Once activated, any dependencies are installed and isolated in that environment. Also see: https://gist.github.com/pandafulmanda/730a9355e088a9970b18275cb9eadef3
If you want to go a step further you can use docker (https://docs.docker.com/language/python/build-images/) to isolate everything, including the operating system, in that case you don't need virtualenv, but to start with I'd play around with virtualenv.
I'm sorry if this is a basic question, but I'm hoping someone can clarify something that may be quite simple.
What I want is to use the tool eyeD3 which is a CLI. The confusing bit is that on the install page it says it should be installed with Pip. Thus, I created a virtual environment and installed the package there.
Okay great, but how do I actually use it now? Because every instruction says to use it as a command line tool. But if it's installed as a pip package then the "eyed3" command is not magically going to be placed in my PATH to be used as intended. So what am I not getting here?
Alternatively I may just download it using sudo dnf install python-eyed3 which should work.
But I really want to educate myself if I'm understanding something wrong, so I can better understand and utilize pip and virtual environments with Python.
I've installed anaconda, but I still want to use python as normal within a Terminal window (zsh). At the moment, running which python shows /Users/USERNAME/opt/anaconda3/bin/python.
I don't want this command to point to my anaconda installation. I want to use python as I have in the past, and for it to point to my python 2.7 installation (/usr/bin/python).
The same issue is present with pip and with python3. How do I change these paths back to their default locations?
I want to start out by saying I personally have never used Anaconda, but I have many friends who have and they always seem to wind up getting into hot water as far as configurations go. If you don't need the data-science specific tools that Anaconda offers (most of which I imagine you can get just as easily by using pip install <package_name>), then I STRONGLY urge you to not use Anaconda. I would suggest you instead use homebrew to install python 3.7 and leave the system version of python 2.7 alone... Anyways...
I recently fixed an issue similar to the one you're describing for a friend. I ended up deleted his anacaonda build and reinstalling fresh from homebrew (link: https://brew.sh/), so this is how I helped him and hopefully this will help you too.
Firstly, I would check the configuration of your ~/.bash_profile (or potentially ~/.bashrc) file. Comment out any lines you find that have to do with Anaconda by preceding with the # character. I believe when anaconda installs it puts the location of the anaconda-version-of-python higher in the PATH hierarchy, therefore you computer sees it first before it has the chance to look in /usr/bin...
Secondly, you need to move the anaconda-python to the trash... I would start by trashing the whole '/Users/USERNAME/opt/anaconda3' directory. If memory serves me correctly anaconda stores other python related things in the /MacitoshHD/Library/Frameworks directory, but don't quote me on that. I would advise looking there and trashing whatever seems to be related to the anaconda install.
After that, in a new terminal (so that your PATH refreshes), I installed homebrew, and then ran the command brew install python3 to install python3. I think perhaps I ran the command recommended in the installer output, something like "brew link python3" to symlink python3 where it needs to be linked after the installation.
Finally, everything is done python2 and python3 are installed and working with no issues. python2 is the system default version and python3 is the homebrew installed version. Feel free to ask any questions and I will try to help more, hopefully those instructions will get you started though.
I'm running MacOS Sierra 10.12.6
By default the system came with Python 2.7.10
I installed Python 3.6.3 (with IDLE) so I can learn Python (3). I understand that this is normal as MacOS may rely on Python 2.x for some programs. Either way, Python3 runs just fine if I run python3 from the command line/terminal, or if I use IDLE (which defaults to Python 3).
Now I want to install some libraries like Beautiful Soup.
And I believe I can install it as follows:
pip3 install beautifulsoup4
which should automatically install it. However, I read that it's recommended to use virtualenv on Mac BEFORE I run the above command. As a newbie, I don't want to mess anything up on my PC, so can anyone point me out how I can do this correctly?
For example, I can follow this link: http://sourabhbajaj.com/mac-setup/Python/virtualenv.html
But I just want to write here to make sure I'm following the right article/commands before I do it. Just being super careful!
Also, can I make a folder with my "virtual environment" and then add sub-folders inside that for each project? Meaning, I don't need to do this everytime, I have one virtual environment and any project that I do just is a subfolder within that space so I can use any libraries that I installed. Just trying to grasp the concept.
Thanks!
Sorry to add confusion.. this can be a tough subject for someone starting out.
The official docs recommend venv, which is similar to, but slightly different than virtualenv.
I would strongly recommend pycharm. It will create your venv for you as part of your project, which you might find helpful.
[Edit: Some other virtual environment features of pycharm that will help you].
If you type in an import statement for a package that isn't installed, it will offer to install it for you.
typing alt-F12 will bring you up a console with your virtual environment active
It syncs up your requirements.txt document for you
It manages your virtual environment path for you (as long as you are running inside pycharm), helping avoid import problems that many newcomers have with virtual environments.
I am not affiliated with pycharm, btw -- I just think it is a great tool for python developers, especially for newcomers, and its treatment of virtual environments is especially helpful.
You create one virtualenv for each project as a way of keeping track of the specific dependencies to keep them minimal which then makes it easier when you want to share projects with other people.
But this is not something you need. No harm comes from installing packages in your real environment as well. So you can safely run
pip3 install beautifulsoup4
I suppose this would apply to anyone using tools like: virtualenv, virtualenvwrapper, pythonbrew, pyenv, etc.
Let me give the use-case. I am using pythonbrew. I want to create a venv, but I get an Import Error saying that there is no "zlib".
So what I do is, I run this command (linux deb/ubuntu terminal):
sudo apt-get install zlib1g-dev
Now the only way I am aware of making sure that the python version I wanted to use with zlib will now work is to uninstall it and then reinstall it again (for anybody that wishes to know, it now works with zlib being recognized).
This takes a lot of time (installing) and makes me wonder what might happen if I have like 5 venvs with multiple setups, only to realize that I need some new module and have to delete my python version again (to reinstall it) and which may also break the 5 venvs (it may, but I'm not sure).
My question is, how could I make sure that the python version will acknowledge something like the zlib installation above without doing a complete re-install of python?
Is there something I could modify in any of the files or perhaps run some update command?