I am currently trying to run Pydev with Pymongo on an Python3.3 Interpreter.
My problem is, I am not able to get it working :-/
First of all I installed Eclipse with Pydev.
Afterwards I tried installing pip to download my Pymongo-Module.
Problem is: it always installs pip for the default 2.7 Version.
I read that you shouldn't change the default system Interpreter (running on Lubuntu 13.04 32-Bit) so I tried to install a second Python3.3 and run it in an virtual environement, but I can't find any detailed Information on how to use everything on my specific problem.
Maybe there is someone out there, that uses a similar configuration and can help me out to get everything running (in a simple way) ?
Thanks in advance,
Eric
You can install packages for a specific version of Python, all you need to do is specify the version of Python you want use from the command-line; e.g. Python2.7 or Python3.
Examples
Python3 pip your_package
Python3 easy_install your_package.
Related
I am working with some python program where I need to import mysql.connector. But I am facing ImportError: No module named connector. I already read answers on same issue and also explore google to find out and try some step to fix still it not fixed.
I am working on MacOS. and I guess by default python 2.7.18 is installed and also I installed python 3.8.9.
So I came to know that I have to install pip install mysql-connector for python 2.X but when I ran this in my terminal it is showing command not found: pip . Then I tried to install pip3 install mysql-connector. for python3 and it got successfully installed.
But Still problem not fixed. Any idea how to fix this?
It could be the case where you are running the Python file with the wrong Python installation. In VS Code we can choose the interpreter using which we want to run our Python file.
By default, the Python extension looks for and uses the first Python
interpreter it finds in the system path. To select a specific
environment, use the Python: Select Interpreter command from the
Command Palette (Ctrl+Shift+P).
Just choose Python 3.8.9 from the list of interpreters. For complete guide you can refer to the documentation:
https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment
You got two Python installed in your system. Python3 and Python2.
Pip3 is just for python3.
You must use pip2 or pip2.7 for work with python2.
Search if you got the pip2 package installed is not then install it.
I have Ubuntu 14.04 LTS. I guess different versions of python are pre-installed in Ubuntu 14.04. Right now when I type 'python' in terminal it opens python 2.7.11, but I guess the default version of Ubuntu 14.04 is 2.7.6. When I type /usr/bin/python it opens the default version. I know this can be done with making aliases. The real problem is, I have installed pygame, cv2 (that is for image processing) using apt-get. These are installed for default version of python i.e python 2.7.6. Also I have installed anaconda with python 2.7.11 using pip, but again 'pip' and anaconda are installed for 2.7.11. I know python 3 is also pre-installed there but I don't use it. Also I have no python version installed in user/local/bin.Now I want to know why this problem is occurring? How can I fix this now? Also how to import all the libraries for one python version(either default or another) and how to use it? How to configure my settings so that I would not have any problem in future?
If you have easy_install installed you can run
sudo easy_install pip
to install pip. As far as installing Anaconda goes, try using this stack overflow question's answer. If you can't get that to work comment explaining the issue.
First of all I want to thanks Bennet for responding to my question so that I was able to figure out what the problem was. Actually the problem was with aliasing. When I installed cv2 or pygame using apt-get, they were installed for default version but when I installed any package by downloading the installer first (like I installed anaconda), it was installed for python 2.7.11 because 'python' was aliased for this version(that is 2.7.11). So, basically make sure that the default version for which you want to install everything is the one which is aliased as 'python', and everything goes fine. I aliased 'python' for the default version and then installed anaconda via installer and now it has been installed default version.
My programming literacy is very basic, but I like programming and I have been taking some MOOC's to bring me into the 21st century.
I started off by taking a course in Python and installed 2.7.11 (from https://www.python.org/downloads/), now I am onto another course that requires Python 3.x
Can I simply install Python 3.x alongside the 2.x version (on my Mac)? Or, will that create all kinds of conflicts and problems? To add to the picture, I am just using the IDLE that comes along with the download.
If the solution involves a bunch of terminal line commands, or coordinating 3 additional downloads of other packages to make it happen, it is already out of my league. Like I said, I am coming into this as nearly a complete novice.
Thanks for you help.
This might help anyone having Error: python 2.7.14 is already installed when trying to install python3 with brew install python3. Due to python2.7 being retired on 2020, python3 is now the same as python and python2 is python#2.
To fix the error, just run brew upgrade python and if you still want python2 you can install it by brew install python2. In my case I did not have to run the final command and I had both python installed.
It shouldn't create any conflicts simply install python3 with brew install python3, also you get more info for doing it correctly in What is the correct way to install python on OS X? question.
NOTE: After installing python3 you would have two python interpreters python3 and python2.7, your python points to python2.7 as long as you don't change it, in other words your default python interpreter is python2.7 and do not change it without serious reason for that.
To run python3 scripts execute them with your python3 interpreter, tools like pip, easy_install, virtualenv for python3 shall be installed with that interpreter (python3).
You might want to look into pyenv: "pyenv lets you easily switch between multiple versions of Python". Also install-able with brew install pyenv
If you like programming you had better get used to doing a bit of setup and juggling of downloads. If you are going to do much python for different projects you would do well to understand virtualenv's before you find your projects' requirements conflicting.
I'm not overly familiar with Linux and am trying to run a Python script that is dependent upon Python 3.4 as well as pymssql. Both Python 2.7 and 3.4 are installed (usr/local/lib/[PYTHON_VERSION_HERE]). pymssql is also installed, except it's installed in the Python 2.7 directory, not the 3.4 directory. When I run my Python script (python3 myscript.py), I get the following error:
File "myscript.py", line 2, in
import pymssql
ImportError: No module named 'pymssql'
My belief is that I need to install pymssql to the Python 3.4 folder, but that's my uneducated opinion. So my question is this:
How can I get my script to run using Python 3.4 as well as use the pymssql package (sorry, probably wrong term there)?
I've tried many different approaches, broken my Ubuntu install (and subsequently reimaged), and at this point don't know what to do. I am a relative novice, so some of the replies I've seen on the web say to use ENV and separate the versions are really far beyond the scope of my understanding. If I have to go that route, then I will, but if there is another (i.e. easier) way to go here, I'd really appreciate it, as this was supposed to just be a tiny thing I need to take care of but it's tied up 12 hours of my life thus far! Thank you in advance.
It is better if when you run python3.4 you can have modules for that version.
Another way to get the desire modules running is install pip for python 3.4
sudo apt-get install python3-pip
Then install the module you want
python3.4 -m pip install pymssql
The easiest way is to use virtual environments instead of system paths or environment scripts. See official Python package installation guide.
All you need to do is to
# Create fresh Python environemnt
virtualenv -p python3.4 my-venv
# Activate it in current shell
source my-venv/bin/activate
# Install packages
pip install mysqlclent
Note that mysqlclient is Python 3.x compatible version.
I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything.
Now, If I type python --version in the terminal, the correct version is started. However, pip is still "tied" to the default version of Python.
How do I go about telling OSX to look at the new version of Python for everything?
Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv.
A common pattern of Python installation on the mac is to use Home Brew which is a package manager for the mac. You can then install python using:
sudo brew update
brew install python
Provided you have the XCode command line tools already installed.
After I think that the Home Brew Python will be the first in the path. If this is not the case, it might be simpler to use a virtualenv by installing the package with the pip provided by the Mac Brew install (/usr/local/Cellar/python/2.7.5/bin/pip).
After this is done you need to create a virtualenv
virtualenv ~/path/to/the/env
and to activate it
source ~/path/to/the/env/bin/activate
This will be a brand new python and your path will be configured correctly (the python and the pip will be the right ones). You can always delete it, deactivate it or source it as needed.