I'm running python 3.9 and my goal is to install and import pyscopg2:
python --version
Python 3.9.12
conda env list
# conda environments:
#
base * /home/doug/anaconda3
Looks like I'm in anaconda base env.
conda install psycopg2
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Now, when I try to import:
Enter python terminal:
python
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
Then try to import:
import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ModuleNotFoundError: No module named 'psycopg2._psycopg'
It looks like /home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2 is masking what is installed into your base environment.
Try running this import from a different directory and/or delete /home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2.
See ModuleNotFoundError: No module named 'psycopg2._psycopg
Related
I am trying to build a wheel file file out of a complete python project. I had followed the steps available online to build wheel file. The wheel is built successfully, it gets installed also but when I try to import in the same environment I get a ModuleNotFoundError
I had followed the steps available online to build wheel file.
(sancus) C:\Users\XXXX\Downloads\sancus-master\sancus-master\sancus\dist>pip install sancus_extraction-0.0.1-py3-none-any.whl
Processing c:\users\XXXX\downloads\sancus-master\sancus-master\sancus\dist\sancus_extraction-0.0.1-py3-none-any.whl
Installing collected packages: sancus-extraction
Successfully installed sancus-extraction-0.0.1
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
(sancus) C:\Users\XXXX\Downloads\sancus-master\sancus-master\sancus\dist>python
Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>> import sancus_extraction
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sancus_extraction'
>>>
I am trying to set up an environment using pyenv and homebrew on Ubuntu 20.04. There are no problems with my system install of python. However, when I install a specific version of python using pyenv I run into the following problem upon running Jupyter:
> jupyter notebook
Traceback (most recent call last):
File "/home/parzydlo/.pyenv/versions/3.10.3/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/notebookapp.py", line 76, in <module>
from .base.handlers import Template404, RedirectWithParams
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/base/handlers.py", line 35, in <module>
from notebook.utils import is_hidden, url_path_join, url_is_absolute, url_escape, urldecode_unix_socket_path
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/site-packages/notebook/utils.py", line 8, in <module>
import ctypes
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
To verify the package is missing:
> python3
Python 3.10.3 (main, Apr 7 2022, 19:51:28) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/parzydlo/.pyenv/versions/3.10.3/lib/python3.10/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
When I switch back to system python:
> pyenv local system
> python3
Python 3.9.12 (main, Mar 23 2022, 21:36:19)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>>
Following numerous threads here on SO I installed libffi-dev and tried reinstalling pyenv python but the problem persists. Perhaps it is worth mentioning that I'm using homebrew as my package manager, but had to install libffi-dev using apt.
Finally, I read [this post on dev.to][1] which suggested the following fix:
CC="$(brew --prefix gcc)/bin/gcc-11" \
pyenv install --verbose 3.10.0
Unfortunately, this too did not resolve the issue.
[1]: https://dev.to/ajkerrigan/homebrew-pyenv-ctypes-oh-my-3d9#isolating-the-useful-change
I have similar issue, the trick is you need to reinstall the same python version, e.g pyenv install -f after all apt install lib**-dev.
Following instructions from numpy.org I have installed numpy
conda install numpy
The installation was successful, as when I type the above command again, I see the message
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
However, when I start python with python and type import numpy I see an error message
Python 3.8.6 (default, Sep 25 2020, 09:36:53)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
How can I get access to numpy?
I am using Ubuntu 20.10 and my conda 4.9.2 is installed in
~/.local/opt/anaconda3/ if this can help.
Thanks!
I've deployed my first package in test.pypi.org as you can find it here
I have installed my package in my virtual environment (.venv).
$ pip list
returns :
Package Version
---------- -------
pip 20.1
pyupurs 0.0.2
setuptools 46.0.0
wheel 0.34.2
But as you can see here, I cannot import it within my interpreter.
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyupurs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyupurs'
Why is this happening? How can I fix it?
In your package pyupurs there is nothing that can be imported under same name. The distribution package pyupurs installs top-level importable package named stateless_file_ops. So you can only do
import stateless_file_ops
If you want to change that you need to change you subdirectory structure perhaps adding a directory pyupurs with file __init__.py in it.
wonder if anyone has tried IntelPython with anaconda. i created an environment as in url link
Intel Python
however, when i try to import pytables, i get: -
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 18:08:47)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import tables
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tables'
Which is strange because i have it running under the non-intel python environment, so i tried checking if pytables was installed under the intelpython environment
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ sudo ./conda upgrade pytables
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /opt/anaconda3:
#
pytables 3.3.0 np112py35_intel_2 [intel] intel
(intelpython) dc#dcpctw:/opt/anaconda3/bin$
So its installed in the environment and should work, any help? thanks
You are running the python executable from /opt/anaconda/bin but you have an activated environment of (intelpython). Change to a different directory, e.g., ~, make sure the first python on your PATH is /opt/anaconda3/envs/intelpython/bin/python, and try the import again.