I usually use PyCharm but, i was trying to run py extension file from terminal.
I have already installed opencv-python.
I tried pip3 install opencv-python also. Nonetheless, I am having the same issue. But, I am able to run those files from PyCharm.
It could be due to the fact that the terminal is using python2 version by default and you need to explicitly specify python3 while running the program to use python3.
You can see the link How Should I Set Default Python Version In Windows? to set your default python version to python3 in Windows.
Related
I'm trying to install packages on multiple versions of Python. I'm currently running 3.8.8, and 3.11.0.
Following this post Install a module using pip for specific python version
called
python3.11 -m pip install pandas
which results in
File "<stdin>", line 1 python3.11 -m pip install pandas SyntaxError: invalid syntax
This seems to indicate an issue with python, so I double checked that python3.11 is installed.
the python3.11 works in isolation seems to work.
I don't understand why the install command isn't working.
If you’re using Linux try just
python3 —-version
In Windows you may need to add path to folder with installed Python to PATH variable.
Check your environment variables, you could try removing the variables pointing to the 3.8 version until you get the packages you want installed.
You could also try navigating to that python 3.11 installation directly, and executing the python shell from there, then run the command.
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.
So I'm trying to install via cmd using a setup.py file..
However, when I try to install it through CMD, this happens:
The first way you were trying to install it is correct python setup.py install, however you need Python 2.x for this installer to work. You are in a Python 3.2 environment and it appears that this module has not been updated to work with Python3 at this time.
http://ocemp.sourceforge.net/manual/installation.html
The print bdist.bdist_base, self.install_dir statement is Python 2.x syntax. If it were compatible with Python3, it would be print(bdist.bdist_base, self.install_dir)
----------
If you require development in both Python3 and Python2, I highly recommend installing Anaconda
https://www.continuum.io/downloads
You can set up multiple environments with whatever versions of Python that you want. Then you can activate each one as necessary.
http://conda.pydata.org/docs/py2or3.html
I'm trying to use python with an excel document and trying to use pywin32 to access COM objects. My problem: I can't figure out install pywin32 so I can use it with iPython. Running the installer, it only detects my python27 installation and installs there.
When I run program with import win32com.client from cmd, it works fine. Trying to do the same in iPython and there is an ImportError. I'm pretty sure this is because their are two different system paths and win32com.client is only on one of them (sys.path in iPython only has things in C:\\Anaconda).
The iPython console is way easier to use than cmd for running and debugging programs, so I would really like to keep using it but I'm stuck.
You are correct that package installed to wrong python installation.
Also if you install pywin32 make sure you use the correct python when you install windows (unlike mac) allows you to run setup.py directly. This will use the 1st python in your path to determine install location.
Standard install:
python setup.py install
On windows the python is optional, but importantly still implied.
type:
where python
at command prompt to see which python will be used to run setup.py
You can also try:
/full_path/python setup.py install
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.