I have installed PyCharm in order to work on Python projects. I have also installed Anaconda to create conda environments for my projects on my machine.
I have create a new project called 'hello-world-ml' and I have created a conda environment called 'hello-world-ml' for my python project.
Within, my python folder I have a script called 'hello-world.py'. Within this script I require the module 'sklearn'. I have activated my conda environment and installed sklearn using the command conda install scikit-learn. When I enter conda list. I can see that the module has been successfully installed within the conda environment.
I have also configure PyCharm to use the Python interpreter from the conda environment. So when I went to type from sklearn... it auto suggested what to import.
When I go to run my script, I get this error:
Traceback (most recent call last):
File "hello-world.py", line 1, in <module>
from sklearn import tree
File "C:\Users\Callu\Anaconda3\envs\hello-world-ml\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\Callu\Anaconda3\envs\hello-world-ml\lib\site-packages\sklearn\base.py", line 11, in <module>
from scipy import sparse
File "C:\Users\Callu\AppData\Roaming\Python\Python36\site-packages\scipy\__init__.py", line 118, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "C:\Users\Callu\AppData\Roaming\Python\Python36\site-packages\scipy\_lib\_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c'
I am unsure how to fix this error. Any help would be greatly appreciated.
In addition, when I deactivate the conda environment and try to run the script it works fine.
Related
The thing is that when updating anaconda, the program made in Python no longer starts, then I leave the error.
The procedure that I have followed has been to make a copy of the Anaconda3 folder that I had installed, delete the Anaconda3 folder, install the new Anaconda3.
From the previous copy I took the Lib from the previous Anaconda3 and pasted it into the new one, and this is the error that appears.
Error:
D:\Anaconda3\lib\site-packages\numpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "D:\xampp\htdocs\RackManagement\app.py", line 3, in <module>
from apps.GT01.gt01 import app_gt01
File "D:\xampp\htdocs\RackManagement\apps\GT01\gt01.py", line 2, in <module>
from modules.db import getCodigos
File "D:\xampp\htdocs\RackManagement\modules\__init__.py", line 1, in <module>
from .tagColor import matchColor
File "D:\xampp\htdocs\RackManagement\modules\tagColor.py", line 1, in <module>
import cv2
File "D:\Anaconda3\lib\cv2\__init__.py", line 8, in <module>
from .cv2 import *
ImportError: numpy.core.multiarray failed to import
Well, I know that one of the ways to fix this would be to do a pip install or download the packages from anaconda, but on the server where this application is, it does not have access to the internet) that is, it is behind a firewall which only allows access to the application, that is to say for the server there is no internet and you cannot connect to download it.
As I have already said, the tests I did was to copy the folders from the old installation to the new one, but it still does not work
I'm new to using Django & Python and am having some difficulty trying to get my manage.py application to run in a virtual environment.
I am receiving the following errors at the top of my models.py file:
I initially thought that this was an issue with pylint not pointing at the right environment (when I switch my Python interpretter to the one outside of the virtual environment, the pylint errors disappear); however, whenever I try to run my server, I get the following error:
(.venv) tjmcerlean#LAPTOP-RKLCBQLO:/mnt/c/Users/tjmce/Desktop/Git/CS50w/Project 2/commerce$ python manage.py runserverTraceback (most recent call last):
File "manage.py", line 10, in main
from django.core.management import execute_from_command_line
File "/mnt/c/Users/tjmce/Desktop/Git/CS50w/Project 2/commerce/.venv/lib/python3.8/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
ModuleNotFoundError: No module named 'django.utils'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 12, in main
raise ImportError(
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
This error appears to suggest that the virtual environment is not activated. However, I activated it using the location of the virtual environment (.venv/bin/activate) and saw that the bash terminal now displays (.venv):
Additionally, when using the (pip freeze) command, I can see that Django is installed within the virtual environment too:
I'm lost as to why the server won't run and would really appreciate any advice.
Thank you!
Calling django.__file__ in activated env reveals the real path:
python -c "import django; print(django.__file__)"
it should looks like /usr/local/lib/python3.8/site-packages/django/__init__.py
then re-check PYTHONPATH environment variable.
Maybe you've installed 2 Django in venv and system-wide but in some of them there is no db. And also remove all of *.pyc files in your working folder.
The problems occur when you don't include a path in virtualenv.
Try adding the path of python on your vscode.
Or, try to install and uninstall the Django projects.
I have created a virtual environment containing packages I need for some python out of tree blocks. When I activate the virtual environment and attempt to run the flowgraph from companion, it complains that the special packages I included in my virtual environment cannot be found.
Interestingly, I can successfully run from the command line the .py version of the flowgraph automatically generated by GnuRadio Companion.
How can I get this to work under Gnu Radio Companion?
As a specific example, I created a virtual environment containing the pandas package and attempted to import pandas in a no_block type custom python block originally created with gr_modtool. I did the install with the virtual environment activated. While running the flowgraph from the command line works fine, I get the following error when attempting to run the same flowgraph from GRC (which was opened from the command line with the virtual environment activated):
Traceback (most recent call last):
File "/home/my_name/devel/gr-my_oot_module/examples/my_flowgraph.py", line 35, in <module>
import my_oot_module
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/my_oot_module/__init__.py", line 39, in <module>
from .my_noblock_block import my_noblock_block
File "/home/my_name/devel/gnuradio3_8/lib/python3.6/dist-packages/my_oot_module/my_noblock_block.py", line 25, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
You have to realize that this is standard python under the hood. If you don't start gnuradio-companion from within your activated environment, Python can't find the modules therein. That's the whole idea of virtual environments.
I haven't used RPy2 for a number of years (and then I only played around a bit). However, I now want to start using Python and R a bit more seriously and decided to re-explore the RPy2 library.
I'm using a Mac running El Capitan. I created a new virtual environment (called env34) using Python 3.4.4 and installed the latest version of pip (19.1.1) using get-pip.py. I then pip installed numpy, pandas and jupyter into the activated environment. I also pip installed RPy2 (but had to include a trusted-host flag):
(env34) $ pip install rpy2 --trusted-host=https://pypi.org/simple/cffi
I also installed the latest version of R (3.6.0) in the default location in Applications folder and edited .bash_profile to create a RHOME environment variable by adding the following:
RHOME="/Library/Frameworks/R.framework/Resources"
export RHOME
Now when I launch Python in the virtual environment, I can import rpy2 with no problems. However, I'm trying to follow the tutorial given at http://heather.cs.ucdavis.edu/~matloff/rpy2.html and when I try to import rpy2.robjects using:
>>> from rpy2.robjects import r
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/robjects/__init__.py", line 14, in <module>
import rpy2.rinterface as rinterface
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface.py", line 5, in <module>
import rpy2.rinterface_lib._rinterface_capi as _rinterface
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface_lib/_rinterface_capi.py", line 8, in <module>
from . import conversion
File "/path_to_virtual_environment/env34/lib/python3.4/site-packages/rpy2/rinterface_lib/conversion.py", line 8, in <module>
from . import _rinterface_capi as _rinterface
ImportError: cannot import name '_rinterface_capi'
As far as I can see, all the files referenced in the message exist in the correct locations.
Can anyone interpret this error message and perhaps offer a workaround?
Thanks in advance.
When I use Anaconda, importing numpy gives me the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File"C:\Users\s140041\Anaconda3\envs\testenv\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: The specified module could not be found.
I have already done a LOT of troubleshooting:
I do not think the issue is path-related, Since Anaconda is my only installation of python on this machine, and the problem persists after a fresh installation of windows. I have not added anaconda to Path right now, since I just use the Anaconda prompt for all my conda related commands.
I do not think it is a problem with the environments, Problem exists on base/root environment of conda as well as on a new conda environment.
Problem is not system-related, was able to reproduce it on 2 seperate systems with specified version.
Problem is not PyCharm related, running python.exe from the root folder also gives the same error.
Uninstalling / reinstalling through conda doesn't work.
Conda does seem to look in the right library for the packages, checked this through print(sys.path) in python.exe, it returns the local library of anaconda where all it's default packages are installed.
Only when I uninstall using conda and re-install using pip everything works fine... Am i doing something wrong here, or is conda broken in this installation of Anaconda?
I just switched from a normal python/venv/pip to Anaconda/conda/environments, but I must say this is not really a warm welcome... Even though I heard that the conda packagement system is better than pip/venv.
UPDATE:
I filed a bug report on github, which can be found here.
https://github.com/conda/conda/issues/7833
Very clear discussion of what went wrong can be found in the bug-report on GitHub:
https://github.com/conda/conda/issues/7833
Summarized, using PyCharm with an unactivated environment is unsupported. So either use anaconda prompt, activate your environment and launch PyCharm from there, or re-install anaconda/mini-conda with the option "add-to-path" checked