Getting : No module named 'clr' after changing python version - python

I had python 3.7.7 32bit installed on my laptop. I installed pip and pythonnet.
I have this line of code in my python project which is executing fine.
import sys, os, clr, time
from pathlib import Path
Now I have installed python 3.7.7 64bit version on my laptop. Before running the application, I changed the current python environment to point to 64bit. Upon changing the env, I'm getting the error :
No module named 'clr'
Do I have install pythonnet again for 64bit. If yes, how to do it again? Because when I try to install again it says
Requirement already satisfied: pythonnet in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(2.5.2) Requirement already satisfied: pycparser in
c:\users\XXXXXX\appdata\local\programs\python\python37-32\lib\site-packages
(from pythonnet) (2.21)
It is referring to python37-32 still. How do I target it to python37 (64bit).

I have stumbled into this issue a lot with my classmates in programming classes. The problem is that different programs point to different versions of Python. Assuming you're using VS Code, you are able to change which Python version to use, by the "Python: Select Interpreter" command.
Assuming you're using the terminal, you can change which Python version to use when you type "python", by changing your PATH environments.

Related

Pip installed a module I want to use, but still getting "module not found" error

I am trying to use the Python module Gdal. I have run pip install gdal and I recieve the message
Requirement already satisfied: gdal in c:\users\willy\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (3.3.1)
and yet when I run import gdal in my Python IDE (I use Spyder), I still get the error no module named gdal
You need to tell Spyder which Python interpreter to use. Point it to the one you're installing the package for, as it seems that it's using a different one.
https://docs.spyder-ide.org/current/faq.html#using-existing-environment
From the documentation it seems you have to call:
from osgeo import gdal
See here
Answer is here in Spyder docs: https://docs.spyder-ide.org/5/faq.html#using-packages-installer
Don't try to use pip install and expect it to work in Spyder. Follow these instructions

Can't import pandas although Its installed (module not found) MBP

Hi Guys I've been searching for more than two hours by now. I searched all over SOF and Youtube but found no answer.
I Have anaconda installed and as they said on the installing instructions pandas and other diferente pakgs are included already, but when I try to import pandas as pd on Jupyer or VS I get the module not found error.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-7dd3504c366f> in <module>
----> 1 import pandas as pd
ModuleNotFoundError: No module named 'pandas'*
I only have python 3.8 installed no other versions. And I've confirmed several times that pandas is installed.
SHOW PANDAS AT TERMINAL
(base) Rogers-MBP:~ rogerrendon$ pip show pandas
Name: pandas
Version: 1.0.5
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org
Author: None
Author-email: None
License: BSD
Location: /Users/rogerrendon/opt/anaconda3/lib/python3.8/site-packages
Requires: python-dateutil, numpy, pytz
Required-by: statsmodels, seaborn
PYTHON VERSION
(base) Rogers-MBP:~ rogerrendon$ python
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
PIP3 INSTALL CHECK
pip3 install pandas
Requirement already satisfied: pandas in ./opt/anaconda3/lib/python3.8/site-packages (1.0.5)
Requirement already satisfied: python-dateutil>=2.6.1 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.13.3 in ./opt/anaconda3/lib/python3.8/site-packages (from pandas) (1.18.5)
Requirement already satisfied: six>=1.5 in ./opt/anaconda3/lib/python3.8/site-packages (from python-dateutil>=2.6.1->pandas) (1.15.0)
Can please somebody help me? I'm loosing my mind hahah
You are using the built-in python from apple instead of Anaconda. During installation there is supposed to be a prompt that asks you something to the effect of "do you want anaconda to be your default python installation". If this didn't come up or you clicked past it too fast, it will not have made any changes to your bash profile (zsh on catalina) that would make your system aware of the new python installation. Some things (like pip) may use other ways to discover the correct distribution to target which is why that seems to find anaconda just fine.
If you open up your user folder and make hidden files visible (cmd shift period), you should find either bash or zsh profile files that control the startup of any system shell you call. If you don't find somewhere in those files a block put in there by the installer (it should be very clear from the comments), then effectively anaconda was installed, but never activated. Try opening a command prompt and calling:
(base) Rogers-MBP:~ rogerrendon$ source /Users/rogerrendon/opt/anaconda3/bin/activate
then if you are running 10.14 or earlier:
(base) Rogers-MBP:~ rogerrendon$ conda init
or if you have Catalina (10.15)
(base) Rogers-MBP:~ rogerrendon$ conda init zsh
I have dealt with similar issues in the past. The first thing to check is to make sure that you don't have multiple python versions installed throughout your computer (unless you require this). If you properly installed anaconda then you should have python within that environment. To uninstall other pythons, go to your uninstall apps page and find the python versions if they exist and remove them.
If after doing this an issue still arises, restart and check your path. Make sure you have paths to ...\anaconda3\Library\usr\bin, ...\anaconda3\Library\bin, and ...\anaconda3\Scripts
Another thing to try is conda installing pandas although anaconda should include this package already.
I've found an issue using hydrogen within Atom (basically allows jupyter to be used in Atom) where the atom search paths set from install are to the wrong package locations. Fixing this could become cumbersome so I would recommend the nuclear option of uninstalling everything and reinstalling if nothing above works.
Go to File->Setting->Project Interpreter->click on plus sign->type 'pandas'->Install Package.

Python Imports - Many Modules not Recognized

I am trying to follow a tutorial book called "Data visualization with Python and Javascript" and am running into many issues importing modules used in the book. I have made sure to do "pip install" on as many of the packages used as possible, and have successfully done it for packages such as SQLAlchemy and matplotlib.
However, when I import modules from SQLAlchemy and even dateutil that are used in the tutorial, I receive an import error, "ImportError: No module named {module}"
On the following lines of code:
from dateutil import parser
from SQLAlchemy import create_engine
This has occurred often enough with different modules that I am beginning to get concerned I can no longer actually follow the tutorial. I had to skip a whole section of how to use SQLAlchemy.
Furthermore, SQLAlchemy is properly installed:
Requirement already up-to-date: sqlalchemy in c:\users\{user}\appdata\local\continuum\miniconda3\lib\site-packages (1.2.15)
What obvious thing am I missing here that needs to happen for me to use these packages and modules?
EDIT:
python --version
Python 3.7.1
pip --version
pip 18.1 from C:\Users\{user}\AppData\Local\Continuum\miniconda3\lib\site-packages\pip (python 3.7)
However, I am using Anaconda for a virtual environment, and PyCharm as my IDE. I have included a screenshot of the projects interpreter for a good measure.Project Interpreter
Furthermore, I have checked that I have pip installed it on both the root and the environment.Root Environment
I think, you have multiple python versions installed.(2.* | 3.*)
You are installing packages in one python version and using another python version.
EDIT:
You can use pip2 install modulename for python2
and pip3 install modulename for python3

Installing and importing Python Modules onto OS X

I've been trying for a couple of hours already. It seems IDLE can't find any third-party module. I am a Python beginner.
Here is some info about my system:
OSX version: 10.11.5
python version: Python 2.7, Python 3.4, Python 3.5
The initial installation using pip (among other methods) seems to work fine. When I repeat the installation, terminal responds with:
Requirement already satisfied (use --upgrade to upgrade): pyperclip in
./anaconda/lib/python3.4/site-packages
However, when I go to IDLE (Python 3.4) and try to import the module, IDLE responds with:
Traceback (most recent call last): File "", line 1, in
import pyperclip ImportError: No module named 'pyperclip'
I have read that it may have something to do with my PATH or some virtual environment. I’ll be frank, I’m not sure what to make of these as they seem beyond my current ability.
This inability to import modules is becoming an almost insurmountable roadblock to advancing with Python. If you can offer any ideas on what I can do or can ELI5 the solution, I am forever in your debt?
It seems you are using conda, but you are trying to install the pyperclip module with pip. Have you tried running conda install pyperclip?
As stated here:
Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side but they do not interoperate either.

Unable to use pymssql in Python 3.5

I have installed pymssql using pip however It is never found when I try to import into a project.
I get the error, No module found 'pymssql'
I have attempted to copy the .pyd file (pymssql-2.1.2-cp35-cp35m-win_amd64.pyd) to the project directory and this is still a problem
So. just using...
import pymssql
...results in the module not being found, If I try to reinstall through pip it states it is installed and requirement is already satisfied.
How can i get this useable
I am using Python 3.5 and Windows 10
Python is installed in Appdata/Local/Programs/Python35
Modules are installed Appdata/Roaming/Python35/site-packages/
Installing the .whl file manually from the Pymssql website resolved the issue and allowed me to use the module in my project!

Categories